cipher87

Untitled

Oct 29th, 2019
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.22 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  3.  
  4.  
  5. global $avia_config, $post_loop_count;
  6.  
  7.  
  8. if(empty($post_loop_count)) $post_loop_count = 1;
  9. $blog_style = !empty($avia_config['blog_style']) ? $avia_config['blog_style'] : avia_get_option('blog_style','multi-big');
  10. if(is_single()) $blog_style = avia_get_option('single_post_style','single-big');
  11.  
  12. $blog_global_style = avia_get_option('blog_global_style',''); //alt: elegant-blog
  13.  
  14. $blog_disabled = ( avia_get_option('disable_blog') == 'disable_blog' ) ? true : false;
  15. if($blog_disabled)
  16. {
  17.     if (current_user_can('edit_posts'))
  18.     {
  19.         $msg =  '<strong>'.__('Admin notice for:' )."</strong><br>".
  20.                         __('Blog Posts', 'avia_framework' )."<br><br>".
  21.                         __('This element was disabled in your theme settings. You can activate it here:' )."<br>".
  22.                        '<a target="_blank" href="'.admin_url('admin.php?page=avia#goto_performance').'">'.__("Performance Settings",'avia_framework' )."</a>";
  23.        
  24.         $content    = "<span class='av-shortcode-disabled-notice'>{$msg}</span>";
  25.        
  26.         echo $content;
  27.     }
  28.    
  29.      return;
  30. }
  31.  
  32.  
  33.  
  34.  
  35. $initial_id = avia_get_the_ID();
  36.  
  37. // check if we got posts to display:
  38. if (have_posts()) :
  39.  
  40.     while (have_posts()) : the_post();
  41.  
  42.        
  43.     /*
  44.      * get the current post id, the current post class and current post format
  45.      */
  46.     $url = "";
  47.     $current_post = array();
  48.     $current_post['post_loop_count']= $post_loop_count;
  49.     $current_post['the_id']     = get_the_ID();
  50.     $current_post['parity']     = $post_loop_count % 2 ? 'odd' : 'even';
  51.     $current_post['last']       = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";
  52.     $current_post['post_type']  = get_post_type($current_post['the_id']);
  53.     $current_post['post_class']     = "post-entry-".$current_post['the_id']." post-loop-".$post_loop_count." post-parity-".$current_post['parity'].$current_post['last']." ".$blog_style;
  54.     $current_post['post_class'] .= ($current_post['post_type'] == "post") ? '' : ' post';
  55.     $current_post['post_format']    = get_post_format() ? get_post_format() : 'standard';
  56.     $current_post['post_layout']    = avia_layout_class('main', false);
  57.     $blog_content = !empty($avia_config['blog_content']) ? $avia_config['blog_content'] : "content";
  58.    
  59.     /*If post uses builder change content to exerpt on overview pages*/
  60.     if( Avia_Builder()->get_alb_builder_status( $current_post['the_id'] ) && !is_singular($current_post['the_id']) && $current_post['post_type'] == 'post')
  61.     {
  62.        $current_post['post_format'] = 'standard';
  63.        $blog_content = "excerpt_read_more";
  64.     }
  65.    
  66.     /**
  67.      * Allows especially for ALB posts to change output to 'content'
  68.      * Supported since 4.5.5
  69.      *
  70.      * @since 4.5.5
  71.      * @return string
  72.      */
  73.     $blog_content = apply_filters( 'avf_blog_content_in_loop', $blog_content, $current_post, $blog_style, $blog_global_style );
  74.    
  75.  
  76.     /*
  77.      * retrieve slider, title and content for this post,...
  78.      */
  79.     $size = strpos($blog_style, 'big') ? (strpos($current_post['post_layout'], 'sidebar') !== false) ? 'entry_with_sidebar' : 'entry_without_sidebar' : 'square';
  80.    
  81.     if(!empty($avia_config['preview_mode']) && !empty($avia_config['image_size']) && $avia_config['preview_mode'] == 'custom') $size = $avia_config['image_size'];
  82.    
  83.     /**
  84.      * @since 4.5.4
  85.      * @return string
  86.      */
  87.     $current_post['slider'] = apply_filters( 'avf_post_featured_image_link', get_the_post_thumbnail( $current_post['the_id'], $size ), $current_post, $size );
  88.    
  89.     /**
  90.      * Backwards comp. to checkbox prior v4.5.3 (now selectbox with '' or '1')
  91.      */
  92.     $hide_featured_image = empty( get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) ? false : true;
  93.     if( is_single( $initial_id ) && $hide_featured_image )
  94.     {
  95.         $current_post['slider'] = '';
  96.     }
  97.    
  98.     $current_post['title']      = get_the_title();
  99.    
  100.     /**
  101.      * Allow 3rd party to hook and return a plugin specific content.
  102.      * This returned content replaces Enfold's standard content building procedure.
  103.      *
  104.      * @since 4.5.7.2
  105.      * @param string
  106.      * @param string $context
  107.      * @return string
  108.      */
  109.     $current_post['content'] = apply_filters( 'avf_the_content', '', 'loop_index' );
  110.     if( '' == $current_post['content'] )
  111.     {
  112.         $current_post['content']    = $blog_content == "content" ? get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow"></span>') : get_the_excerpt();
  113.         $current_post['content']    = $blog_content == "excerpt_read_more" ? $current_post['content'].'<div class="read-more-link"><a href="'.get_permalink().'" class="more-link">'.__('Read more','avia_framework').'<span class="more-link-arrow"></span></a></div>' : $current_post['content'];
  114.         $current_post['before_content'] = "";
  115.  
  116.         /*
  117.          * ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)
  118.          */
  119.         $current_post   = apply_filters( 'post-format-'.$current_post['post_format'], $current_post );
  120.         $with_slider    = empty($current_post['slider']) ? "" : "with-slider";
  121.        
  122.         /*
  123.          * ... last apply the default wordpress filters to the content
  124.          */
  125.         $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content'] ));
  126.     }
  127.  
  128.     /*
  129.      * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
  130.      */
  131.     extract($current_post);
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.     /*
  141.      * render the html:
  142.      */
  143.  
  144.     echo "<article class='".implode(" ", get_post_class('post-entry post-entry-type-'.$post_format . " " . $post_class . " ".$with_slider))."' ".avia_markup_helper(array('context' => 'entry','echo'=>false)).">";
  145.        
  146.        
  147.        
  148.         //default link for preview images
  149.         $link = !empty($url) ? $url : get_permalink();
  150.        
  151.         //preview image description
  152.         $desc = get_post( get_post_thumbnail_id() );
  153.         if(is_object($desc))  $desc = $desc -> post_excerpt;
  154.         $featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
  155.  
  156.         //on single page replace the link with a fullscreen image
  157.         if(is_singular())
  158.         {
  159.             $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
  160.         }
  161.  
  162.         if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  163.             //echo preview image
  164.             if (strpos($blog_global_style, 'elegant-blog') === false) {
  165.                 if (strpos($blog_style, 'big') !== false) {
  166.                     if ($slider) $slider = '<a href="' . $link . '" title="' . $featured_img_desc . '">' . $slider . '</a>';
  167.                     if ($slider) echo '<div class="big-preview ' . $blog_style . '">' . $slider . '</div>';
  168.                 }
  169.  
  170.                 if (!empty($before_content))
  171.                     echo '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
  172.             }
  173.         }
  174.        
  175.         echo "<div class='blog-meta'>";
  176.  
  177.         $blog_meta_output = "";
  178.         $icon =  '<span class="iconfont" '.av_icon_string($post_format).'></span>';
  179.  
  180.             if(strpos($blog_style, 'multi') !== false)
  181.             {
  182.                 $gravatar = "";
  183.                 $link = get_post_format_link($post_format);
  184.                 if($post_format == 'standard')
  185.                 {
  186.                     $author_name = apply_filters('avf_author_name', get_the_author_meta('display_name', $post->post_author), $post->post_author);
  187.                     $author_email = apply_filters('avf_author_email', get_the_author_meta('email', $post->post_author), $post->post_author);
  188.                    
  189.                     $gravatar_alt = esc_html($author_name);
  190.                     $gravatar = get_avatar($author_email, '81', "blank", $gravatar_alt);
  191.                     $link = get_author_posts_url($post->post_author);
  192.                 }
  193.  
  194.                 $blog_meta_output = "<a href='{$link}' class='post-author-format-type'><span class='rounded-container'>".$gravatar.$icon."</span></a>";
  195.             }
  196.             else if(strpos($blog_style, 'small')  !== false)
  197.             {
  198.                 $blog_meta_output = "<a href='{$link}' class='small-preview' title='{$featured_img_desc}'>".$slider.$icon."</a>";
  199.             }
  200.  
  201.         echo apply_filters('avf_loop_index_blog_meta', $blog_meta_output);
  202.  
  203.         echo "</div>";
  204.  
  205.         echo "<div class='entry-content-wrapper clearfix {$post_format}-content'>";
  206.             echo '<header class="entry-content-header">';
  207.  
  208.                 if ($blog_style == 'bloglist-compact') {
  209.                     $format = get_post_format();
  210.                     echo "<span class=' fallback-post-type-icon' ".av_icon_string($format)."></span>";
  211.                 }
  212.  
  213.                 $close_header   = "</header>";
  214.                
  215.                 $content_output  =  '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
  216.                 $content_output .=  $content;
  217.                 $content_output .=  '</div>';
  218.                
  219.                
  220.                 $taxonomies  = get_object_taxonomies(get_post_type($the_id));
  221.                 $cats = '';
  222.                 $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array('post_tag','post_format') );
  223.                 $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', $excluded_taxonomies, get_post_type($the_id), $the_id);
  224.  
  225.                 if(!empty($taxonomies))
  226.                 {
  227.                     foreach($taxonomies as $taxonomy)
  228.                     {
  229.                         if(!in_array($taxonomy, $excluded_taxonomies))
  230.                         {
  231.                             $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  232.                         }
  233.                     }
  234.                 }
  235.                
  236.                
  237.                
  238.                 //elegant blog
  239.                 //prev: if( $blog_global_style == 'elegant-blog' )
  240.                 if( strpos($blog_global_style, 'elegant-blog') !== false )
  241.                 {
  242.                     $cat_output = "";
  243.                    
  244.                     if(!empty($cats))
  245.                     {
  246.                         $cat_output .= '<span class="blog-categories minor-meta">';
  247.                         $cat_output .= $cats;
  248.                         $cat_output .= '</span>';
  249.                         $cats = "";
  250.                     }
  251.  
  252.                 if ( in_array( $blog_style, array('bloglist-compact','bloglist-excerpt') ) ) {
  253.                  echo $title;
  254.                 }
  255.                 else {
  256.  
  257.                     // The wrapper div prevents the Safari reader from displaying the content twice  ¯\_(ツ)_/¯
  258.                     echo '<div class="av-heading-wrapper">';
  259.                     if (strpos($blog_global_style, 'modern-blog') === false){
  260.                         echo $cat_output.$title;
  261.                     }
  262.                     else {
  263.                         echo $title.$cat_output;
  264.                     }
  265.                     echo '</div>';
  266.                 }
  267.  
  268.                 if ($blog_style !== 'bloglist-compact') :
  269.                
  270.                     echo "<span class='post-meta-infos'>";
  271.        
  272.                     echo "<time class='date-container minor-meta updated' >" . __('Posted on ','avia_framework') . get_the_time(get_option('date_format'))."</time>";
  273.                     echo "<span class='text-sep text-sep-date'>/</span>";
  274.        
  275.        
  276.        
  277.                         if ( get_comments_number() != "0" || comments_open() ){
  278.        
  279.                         echo "<span class='comment-container minor-meta'>";
  280.                         comments_popup_link(  "0 ".__('Comments','avia_framework'),
  281.                                               "1 ".__('Comment' ,'avia_framework'),
  282.                                               "% ".__('Comments','avia_framework'),'comments-link',
  283.                                               "".__('Comments Disabled','avia_framework'));
  284.                         echo "</span>";
  285.                         echo "<span class='text-sep text-sep-comment'>/</span>";
  286.                         }
  287.        
  288.        
  289.                         if(!empty($cats))
  290.                         {
  291.                             echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";
  292.                             echo $cats;
  293.                             echo '</span><span class="text-sep text-sep-cat">/</span>';
  294.                         }
  295.        
  296.        
  297.                         echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." ";
  298.                         echo '<span class="entry-author-link" >';
  299.                         echo '<span class="vcard author"><span class="fn">';
  300.                         the_author_posts_link();
  301.                         echo '</span></span>';
  302.                         echo '</span>';
  303.                         echo '</span>';
  304.        
  305.                         if ($blog_style == 'bloglist-simple') {
  306.                             echo '<div class="read-more-link"><a href="'.get_permalink().'" class="more-link">'.__('Read more','avia_framework').'<span class="more-link-arrow"></span></a></div>';
  307.                         }
  308.        
  309.                     echo '</span>';
  310.        
  311.                 endif; // display meta-infos on all layouts except bloglist-compact
  312.  
  313.  
  314.                     echo $close_header;
  315.                     $close_header = "";
  316.  
  317.  
  318.                    if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  319.  
  320.                        echo '<span class="av-vertical-delimiter"></span>';
  321.  
  322.                        //echo preview image
  323.                        if (strpos($blog_style, 'big') !== false) {
  324.                            if ($slider) $slider = '<a href="' . $link . '" title="' . $featured_img_desc . '">' . $slider . '</a>';
  325.                            if ($slider) echo '<div class="big-preview ' . $blog_style . '">' . $slider . '</div>';
  326.                        }
  327.  
  328.  
  329.                        if (!empty($before_content))
  330.                            echo '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
  331.  
  332.  
  333.                        echo $content_output;
  334.                    }
  335.                    
  336.                     $cats = "";
  337.                     $title = "";
  338.                     $content_output = "";
  339.                 }
  340.                
  341.                
  342.                
  343.                
  344.                 echo $title;
  345.  
  346.             echo $close_header;
  347.  
  348.  
  349.             // echo the post content
  350.             if ( $blog_style == 'bloglist-excerpt'){
  351.                 the_excerpt();
  352.                 echo '<div class="read-more-link"><a href="'.get_permalink().'" class="more-link">'.__('Read more','avia_framework').'<span class="more-link-arrow"></span></a></div>';
  353.             }
  354.  
  355.             if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  356.                 echo $content_output;
  357.             }
  358.  
  359.  
  360.             echo '<footer class="entry-footer">';
  361.  
  362.             $avia_wp_link_pages_args = apply_filters('avf_wp_link_pages_args', array(
  363.                                                                                     'before' =>'<nav class="pagination_split_post">'.__('Pages:','avia_framework'),
  364.                                                                                     'after'  =>'</nav>',
  365.                                                                                     'pagelink' => '<span>%</span>',
  366.                                                                                     'separator'        => ' ',
  367.                                                                                     ));
  368.  
  369.             wp_link_pages($avia_wp_link_pages_args);
  370.  
  371.             if(is_single() && !post_password_required())
  372.             {
  373.                 //tags on single post
  374.                 if(has_tag())
  375.                 {
  376.                     echo '<span class="blog-tags minor-meta">';
  377.                     the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> ');
  378.                     echo '</span></span>';
  379.                 }
  380.                
  381.                 //share links on single post
  382.                 avia_social_share_links();
  383.    
  384.             }
  385.            
  386.             do_action('ava_after_content', $the_id, 'post');
  387.  
  388.             echo '</footer>';
  389.  
  390.         echo "<div class='post_delimiter'></div>";
  391.         echo "</div>";
  392.         echo "<div class='post_author_timeline'></div>";
  393.         echo av_blog_entry_markup_helper($current_post['the_id']);
  394.     echo "</article>";
  395.  
  396.     $post_loop_count++;
  397.     endwhile;
  398.     else:
  399.  
  400.             $default_heading = 'h1';
  401.             $args = array(
  402.                         'heading'       => $default_heading,
  403.                         'extra_class'   => ''
  404.                     );
  405.            
  406.             /**
  407.              * @since 4.5.5
  408.              * @return array
  409.              */
  410.             $args = apply_filters( 'avf_customize_heading_settings', $args, 'loop_index::nothing_found', array() );
  411.            
  412.             $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  413.             $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : '';
  414. ?>
  415.  
  416.     <article class="entry">
  417.         <header class="entry-content-header">
  418.             <?php echo "<{$heading} class='post-title entry-title {$css}'>" . __( 'Nothing Found', 'avia_framework' ) . "</{$heading}>"; ?>
  419.         </header>
  420.  
  421.         <p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
  422.  
  423.         <footer class="entry-footer"></footer>
  424.     </article>
  425.  
  426. <?php
  427.  
  428.     endif;
  429.  
  430.     if(empty($avia_config['remove_pagination'] ))
  431.     {
  432.         echo "<div class='{$blog_style}'>".avia_pagination('', 'nav')."</div>";
  433.     }
Advertisement
Add Comment
Please, Sign In to add comment