Guest User

Untitled

a guest
Mar 23rd, 2020
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.07 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.     $current_post['content']    = $blog_content == "content" ? get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow"></span>') : get_the_excerpt();
  100.     $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'];
  101.     $current_post['before_content'] = "";
  102.  
  103.     /*
  104.      * ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)
  105.      */
  106.     $current_post   = apply_filters( 'post-format-'.$current_post['post_format'], $current_post );
  107.     $with_slider    = empty($current_post['slider']) ? "" : "with-slider";
  108.     /*
  109.      * ... last apply the default wordpress filters to the content
  110.      */
  111.      
  112.    
  113.     $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content'] ));
  114.  
  115.     /*
  116.      * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
  117.      */
  118.     extract($current_post);
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.     /*
  128.      * render the html:
  129.      */
  130.  
  131.     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)).">";
  132.        
  133.        
  134.        
  135.         //default link for preview images
  136.         $link = !empty($url) ? $url : get_permalink();
  137.        
  138.         //preview image description
  139.         $desc = get_post( get_post_thumbnail_id() );
  140.         if(is_object($desc))  $desc = $desc -> post_excerpt;
  141.         $featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
  142.  
  143.         //on single page replace the link with a fullscreen image
  144.         if(is_singular())
  145.         {
  146.             $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
  147.         }
  148.  
  149.         if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  150.             //echo preview image
  151.             if (strpos($blog_global_style, 'elegant-blog') === false) {
  152.                 if (strpos($blog_style, 'big') !== false) {
  153.                     if ($slider) $slider = '<a href="' . $link . '" title="' . $featured_img_desc . '">' . $slider . '</a>';
  154.                     if ($slider) echo '<div class="big-preview ' . $blog_style . '">' . $slider . '</div>';
  155.                 }
  156.  
  157.                 if (!empty($before_content))
  158.                     echo '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
  159.             }
  160.         }
  161.        
  162.         echo "<div class='blog-meta'>";
  163.  
  164.         $blog_meta_output = "";
  165.         $icon =  '<span class="iconfont" '.av_icon_string($post_format).'></span>';
  166.  
  167.             if(strpos($blog_style, 'multi') !== false)
  168.             {
  169.                 $gravatar = "";
  170.                 $link = get_post_format_link($post_format);
  171.                 if($post_format == 'standard')
  172.                 {
  173.                     $author_name = apply_filters('avf_author_name', get_the_author_meta('display_name', $post->post_author), $post->post_author);
  174.                     $author_email = apply_filters('avf_author_email', get_the_author_meta('email', $post->post_author), $post->post_author);
  175.                    
  176.                     $gravatar_alt = esc_html($author_name);
  177.                     $gravatar = get_avatar($author_email, '81', "blank", $gravatar_alt);
  178.                     $link = get_author_posts_url($post->post_author);
  179.                 }
  180.  
  181.                 $blog_meta_output = "<a href='{$link}' class='post-author-format-type'><span class='rounded-container'>".$gravatar.$icon."</span></a>";
  182.             }
  183.             else if(strpos($blog_style, 'small')  !== false)
  184.             {
  185.                 $blog_meta_output = "<a href='{$link}' class='small-preview' title='{$featured_img_desc}'>".$slider.$icon."</a>";
  186.             }
  187.  
  188.         echo apply_filters('avf_loop_index_blog_meta', $blog_meta_output);
  189.  
  190.         echo "</div>";
  191.  
  192.         echo "<div class='entry-content-wrapper clearfix {$post_format}-content'>";
  193.             echo '<header class="entry-content-header">';
  194.  
  195.                 if ($blog_style == 'bloglist-compact') {
  196.                     $format = get_post_format();
  197.                     echo "<span class=' fallback-post-type-icon' ".av_icon_string($format)."></span>";
  198.                 }
  199.  
  200.                 $close_header   = "</header>";
  201.                
  202.                 $content_output  =  '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
  203.                 $content_output .=  $content;
  204.                 $content_output .=  '</div>';
  205.                
  206.                
  207.                 $taxonomies  = get_object_taxonomies(get_post_type($the_id));
  208.                 $cats = '';
  209.                 $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array('post_tag','post_format') );
  210.                 $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', $excluded_taxonomies, get_post_type($the_id), $the_id);
  211.  
  212.                 if(!empty($taxonomies))
  213.                 {
  214.                     foreach($taxonomies as $taxonomy)
  215.                     {
  216.                         if(!in_array($taxonomy, $excluded_taxonomies))
  217.                         {
  218.                             $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  219.                         }
  220.                     }
  221.                 }
  222.                
  223.                
  224.                
  225.                 //elegant blog
  226.                 //prev: if( $blog_global_style == 'elegant-blog' )
  227.                 if( strpos($blog_global_style, 'elegant-blog') !== false )
  228.                 {
  229.                     $cat_output = "";
  230.                    
  231.                     if(!empty($cats))
  232.                     {
  233.                         $cat_output .= '<span class="blog-categories minor-meta">';
  234.                         $cat_output .= $cats;
  235.                         $cat_output .= '</span>';
  236.                         $cats = "";
  237.                     }
  238.  
  239.                 if ( in_array( $blog_style, array('bloglist-compact','bloglist-excerpt') ) ) {
  240.                  echo $title;
  241.                 }
  242.                 else {
  243.  
  244.                     // The wrapper div prevents the Safari reader from displaying the content twice  ¯\_(ツ)_/¯
  245.                     /*
  246.                     echo '<div class="av-heading-wrapper">';
  247.                     if (strpos($blog_global_style, 'modern-blog') === false){
  248.                         echo $cat_output.$title;
  249.                     }
  250.                     else {
  251.                         echo $title.$cat_output;
  252.                     }
  253.                     echo '</div>';
  254.                     */
  255.                 }
  256.  
  257.  
  258.                     echo $close_header;
  259.                     $close_header = "";
  260.  
  261.  
  262.                    if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  263.                         /*
  264.                        echo '<span class="av-vertical-delimiter"></span>';
  265.                        */
  266.  
  267.                        //echo preview image
  268.                        if (strpos($blog_style, 'big') !== false) {
  269.                            if ($slider) $slider = '<a href="' . $link . '" title="' . $featured_img_desc . '">' . $slider . '</a>';
  270.                            if ($slider) echo '<div class="big-preview ' . $blog_style . '">' . $slider . '</div>';
  271.                            echo '<div class="new-header">';
  272.                            echo '<div class="post-date">' . get_the_date( 'F j, Y' ) . '</div>';
  273.                            echo $title.$cat_output;
  274.                            echo '</div>';
  275.                        }
  276.  
  277.  
  278.                        if (!empty($before_content))
  279.                            echo '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
  280.  
  281.  
  282.                        echo $content_output;
  283.                    }
  284.                    
  285.                     $cats = "";
  286.                     $title = "";
  287.                     $content_output = "";
  288.                 }
  289.                
  290.                
  291.                
  292.                
  293.                 echo $title;
  294.  
  295.                 if ($blog_style !== 'bloglist-compact') :
  296.                
  297.                     echo "<span class='post-meta-infos'>";
  298.  
  299.                     echo "<time class='date-container minor-meta updated' >".get_the_time(get_option('date_format'))."</time>";
  300.                     echo "<span class='text-sep text-sep-date'>/</span>";
  301.  
  302.  
  303.  
  304.                         if ( get_comments_number() != "0" || comments_open() ){
  305.  
  306.                         echo "<span class='comment-container minor-meta'>";
  307.                         comments_popup_link(  "0 ".__('Comments','avia_framework'),
  308.                                               "1 ".__('Comment' ,'avia_framework'),
  309.                                               "% ".__('Comments','avia_framework'),'comments-link',
  310.                                               "".__('Comments Disabled','avia_framework'));
  311.                         echo "</span>";
  312.                         echo "<span class='text-sep text-sep-comment'>/</span>";
  313.                         }
  314.  
  315.  
  316.                         if(!empty($cats))
  317.                         {
  318.                             echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";
  319.                             echo $cats;
  320.                             echo '</span><span class="text-sep text-sep-cat">/</span>';
  321.                         }
  322.  
  323.  
  324.                         echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." ";
  325.                         echo '<span class="entry-author-link" >';
  326.                         echo '<span class="vcard author"><span class="fn">';
  327.                         the_author_posts_link();
  328.                         echo '</span></span>';
  329.                         echo '</span>';
  330.                         echo '</span>';
  331.  
  332.                         if ($blog_style == 'bloglist-simple') {
  333.                             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>';
  334.                         }
  335.  
  336.                     echo '</span>';
  337.  
  338.                 endif; // display meta-infos on all layouts except bloglist-compact
  339.  
  340.             echo $close_header;
  341.  
  342.  
  343.             // echo the post content
  344.             if ( $blog_style == 'bloglist-excerpt'){
  345.                 the_excerpt();
  346.                 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>';
  347.             }
  348.  
  349.             if ( !in_array( $blog_style, array('bloglist-simple', 'bloglist-compact', 'bloglist-excerpt') ) ) {
  350.                 echo $content_output;
  351.             }
  352.  
  353.  
  354.             echo '<footer class="entry-footer">';
  355.  
  356.             $avia_wp_link_pages_args = apply_filters('avf_wp_link_pages_args', array(
  357.                                                                                     'before' =>'<nav class="pagination_split_post">'.__('Pages:','avia_framework'),
  358.                                                                                     'after'  =>'</nav>',
  359.                                                                                     'pagelink' => '<span>%</span>',
  360.                                                                                     'separator'        => ' ',
  361.                                                                                     ));
  362.  
  363.             wp_link_pages($avia_wp_link_pages_args);
  364.  
  365.             if(is_single() && !post_password_required())
  366.             {
  367.                 //tags on single post
  368.                 if(has_tag())
  369.                 {
  370.                     echo '<span class="blog-tags minor-meta">';
  371.                     the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> ');
  372.                     echo '</span></span>';
  373.                 }
  374.                
  375.                 //share links on single post
  376.                 avia_social_share_links();
  377.    
  378.             }
  379.            
  380.             do_action('ava_after_content', $the_id, 'post');
  381.  
  382.             echo '</footer>';
  383.  
  384.         echo "<div class='post_delimiter'></div>";
  385.         echo "</div>";
  386.         echo "<div class='post_author_timeline'></div>";
  387.         echo av_blog_entry_markup_helper($current_post['the_id']);
  388.     echo "</article>";
  389.  
  390.     $post_loop_count++;
  391.     endwhile;
  392.     else:
  393.  
  394.             $default_heading = 'h1';
  395.             $args = array(
  396.                         'heading'       => $default_heading,
  397.                         'extra_class'   => ''
  398.                     );
  399.            
  400.             /**
  401.              * @since 4.5.5
  402.              * @return array
  403.              */
  404.             $args = apply_filters( 'avf_customize_heading_settings', $args, 'loop_index::nothing_found', array() );
  405.            
  406.             $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  407.             $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : '';
  408. ?>
  409.  
  410.     <article class="entry">
  411.         <header class="entry-content-header">
  412.             <?php echo "<{$heading} class='post-title entry-title {$css}'>" . __( 'Nothing Found', 'avia_framework' ) . "</{$heading}>"; ?>
  413.         </header>
  414.  
  415.         <p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
  416.  
  417.         <footer class="entry-footer"></footer>
  418.     </article>
  419.  
  420. <?php
  421.  
  422.     endif;
  423.  
  424.     if(empty($avia_config['remove_pagination'] ))
  425.     {
  426.         echo "<div class='{$blog_style}'>".avia_pagination('', 'nav')."</div>";
  427.     }
Advertisement
Add Comment
Please, Sign In to add comment