Guest User

loop-index.php

a guest
Jun 21st, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.56 KB | None | 0 0
  1. <?php
  2. global $avia_config, $post_loop_count;
  3.  
  4.  
  5. if(empty($post_loop_count)) $post_loop_count = 1;
  6. $blog_style = !empty($avia_config['blog_style']) ? $avia_config['blog_style'] : avia_get_option('blog_style','multi-big');
  7. if(is_single()) $blog_style = avia_get_option('single_post_style','single-big');
  8. $blog_content = !empty($avia_config['blog_content']) ? $avia_config['blog_content'] : "content";
  9. $initial_id = avia_get_the_ID();
  10.  
  11. // check if we got posts to display:
  12. if (have_posts()) :
  13.  
  14.     while (have_posts()) : the_post();
  15.  
  16.     /*
  17.      * get the current post id, the current post class and current post format
  18.      */
  19.  
  20.     $current_post = array();
  21.     $current_post['post_loop_count']= $post_loop_count;
  22.     $current_post['the_id']     = get_the_ID();
  23.     $current_post['parity']     = $post_loop_count % 2 ? 'odd' : 'even';
  24.     $current_post['last']       = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";
  25.     $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;
  26.     $current_post['post_format']    = get_post_format() ? get_post_format() : 'standard';
  27.     $current_post['post_layout']    = avia_layout_class('main', false);
  28.  
  29.     /*
  30.      * retrieve slider, title and content for this post,...
  31.      */
  32.     $size = strpos($blog_style, 'big') ? (strpos($current_post['post_layout'], 'sidebar') !== false) ? 'entry_with_sidebar' : 'entry_without_sidebar' : 'square';
  33.     if(!empty($avia_config['preview_mode']) && !empty($avia_config['image_size']) && $avia_config['preview_mode'] == 'custom') $size = $avia_config['image_size'];
  34.     $current_post['slider']     = get_the_post_thumbnail($current_post['the_id'], $size);
  35.    
  36.     if(is_single($initial_id) && get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) $current_post['slider'] = "";
  37.    
  38.    
  39.     $current_post['title']      = get_the_title();
  40.     $current_post['content']    = $blog_content == "content" ? get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow">  &rarr;</span>') : get_the_excerpt();
  41.     $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">  &rarr;</span></a></div>' : $current_post['content'];
  42.     $current_post['before_content'] = "";
  43.  
  44.     /*
  45.      * ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)
  46.      */
  47.     $current_post   = apply_filters( 'post-format-'.$current_post['post_format'], $current_post );
  48.     $with_slider    = empty($current_post['slider']) ? "" : "with-slider";
  49.     /*
  50.      * ... last apply the default wordpress filters to the content
  51.      */
  52.     $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content'] ));
  53.  
  54.     /*
  55.      * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
  56.      */
  57.     extract($current_post);
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.     /*
  67.      * render the html:
  68.      */
  69.  
  70.     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)).">";
  71.  
  72.         //default link for preview images
  73.         $link = !empty($url) ? $url : get_permalink();
  74.        
  75.         //preview image description
  76.         $featured_img_desc = the_title_attribute('echo=0');
  77.        
  78.         if(is_single()) {
  79.         echo $title;
  80.         }
  81.  
  82.         //on single page replace the link with a fullscreen image
  83.         if(is_singular())
  84.         {
  85.             $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
  86.         }
  87.  
  88.  
  89.         //echo preview image
  90.         if(strpos($blog_style, 'big') !== false)
  91.         {
  92.             if($slider) $slider = '<a href="'.$link.'" title="'.$featured_img_desc.'">'.$slider.'</a>';
  93.             if($slider) echo '<div class="big-preview '.$blog_style.'">'.$slider.'</div>';
  94.         }
  95.  
  96.         if(!empty($before_content))
  97.             echo '<div class="big-preview '.$blog_style.'">'.$before_content.'</div>';
  98.  
  99.         echo "<div class='blog-meta'>";
  100.  
  101.         $blog_meta_output = "";
  102.         $icon =  '<span class="iconfont" '.av_icon_string($post_format).'></span>';
  103.  
  104.             if(strpos($blog_style, 'multi') !== false)
  105.             {
  106.                 $gravatar = "";
  107.                 $link = get_post_format_link($post_format);
  108.                 if($post_format == 'standard')
  109.                 {
  110.                     $author_name = apply_filters('avf_author_name', get_the_author_meta('display_name', $post->post_author), $post->post_author);
  111.             $author_email = apply_filters('avf_author_email', get_the_author_meta('email', $post->post_author), $post->post_author);
  112.                    
  113.             $gravatar_alt = esc_html($author_name);
  114.             $gravatar = get_avatar($author_email, '81', "blank", $gravatar_alt);
  115.             $link = get_author_posts_url($post->post_author);
  116.                 }
  117.  
  118.                 $blog_meta_output = "<a href='{$link}' class='post-author-format-type'><span class='rounded-container'>".$gravatar.$icon."</span></a>";
  119.             }
  120.             else if(strpos($blog_style, 'small')  !== false)
  121.             {
  122.                 $blog_meta_output = "<a href='{$link}' class='small-preview' title='{$featured_img_desc}'>".$slider.$icon."</a>";
  123.             }
  124.  
  125.         echo apply_filters('avf_loop_index_blog_meta', $blog_meta_output);
  126.  
  127.         echo "</div>";
  128.  
  129.         echo "<div class='entry-content-wrapper clearfix {$post_format}-content'>";
  130.             echo '<header class="entry-content-header">';
  131.             if(!is_single()) {
  132.             echo $title;
  133.             }
  134.            
  135.                 echo "<span class='post-meta-infos'>";
  136.                 $markup = avia_markup_helper(array('context' => 'entry_time','echo'=>false));
  137.                 echo "<time class='date-container minor-meta updated' $markup>".get_the_time(get_option('date_format'))."</time>";
  138.                 echo "<span class='text-sep text-sep-date'>/</span>";
  139.  
  140.  
  141.  
  142.                     if ( get_comments_number() != "0" || comments_open() ){
  143.  
  144.                     echo "<span class='comment-container minor-meta'>";
  145.                     comments_popup_link(  "0 ".__('Comments','avia_framework'),
  146.                                           "1 ".__('Comment' ,'avia_framework'),
  147.                                           "% ".__('Comments','avia_framework'),'comments-link',
  148.                                           "".__('Comments Disabled','avia_framework'));
  149.                     echo "</span>";
  150.                     echo "<span class='text-sep text-sep-comment'>/</span>";
  151.                     }
  152.  
  153.  
  154.                     $taxonomies  = get_object_taxonomies(get_post_type($the_id));
  155.                     $cats = '';
  156.                     $excluded_taxonomies =  apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'), get_post_type($the_id), $the_id);
  157.  
  158.                     if(!empty($taxonomies))
  159.                     {
  160.                         foreach($taxonomies as $taxonomy)
  161.                         {
  162.                             if(!in_array($taxonomy, $excluded_taxonomies))
  163.                             {
  164.                                 $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
  165.                             }
  166.                         }
  167.                     }
  168.  
  169.                     if(!empty($cats))
  170.                     {
  171.                         echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";
  172.                         echo $cats;
  173.                         echo '</span><span class="text-sep text-sep-cat">/</span>';
  174.                     }
  175.  
  176.  
  177.                     echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." ";
  178.                     echo '<span class="entry-author-link" '.avia_markup_helper(array('context' => 'author_name','echo'=>false)).'>';
  179.                     echo '<span class="vcard author"><span class="fn">';
  180.                     the_author_posts_link();
  181.                     echo '</span></span>';
  182.                     echo '</span>';
  183.                     echo '</span>';
  184.                 echo '</span>';
  185.             echo '</header>';
  186.  
  187.  
  188.             // echo the post content
  189.             echo '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
  190.             echo $content;
  191.             echo '</div>';
  192.  
  193.             echo '<footer class="entry-footer">';
  194.  
  195.             $avia_wp_link_pages_args = apply_filters('avf_wp_link_pages_args', array(
  196.                                                                                     'before' =>'<nav class="pagination_split_post">'.__('Pages:','avia_framework'),
  197.                                                                                     'after'  =>'</nav>',
  198.                                                                                     'pagelink' => '<span>%</span>',
  199.                                                                                     'separator'        => ' ',
  200.                                                                                     ));
  201.  
  202.             wp_link_pages($avia_wp_link_pages_args);
  203.  
  204.             if(is_single() && !post_password_required())
  205.             {
  206.                 //tags on single post
  207.                 if(has_tag())
  208.                 {
  209.                     echo '<span class="blog-tags minor-meta">';
  210.                     the_tags('<strong>'.__('Tags:','avia_framework').'</strong><span> ');
  211.                     echo '</span></span>';
  212.                 }
  213.                
  214.                 //share links on single post
  215.                 avia_social_share_links();
  216.    
  217.             }
  218.            
  219.             do_action('ava_after_content', $the_id, 'post');
  220.  
  221.             echo '</footer>';
  222.  
  223.         echo "<div class='post_delimiter'></div>";
  224.         echo "</div>";
  225.         echo "<div class='post_author_timeline'></div>";
  226.     echo "</article>";
  227.  
  228.     $post_loop_count++;
  229.     endwhile;
  230.     else:
  231.  
  232. ?>
  233.  
  234.     <article class="entry">
  235.         <header class="entry-content-header">
  236.             <h1 class='post-title entry-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1>
  237.         </header>
  238.  
  239.         <p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p>
  240.  
  241.         <footer class="entry-footer"></footer>
  242.     </article>
  243.  
  244. <?php
  245.  
  246.     endif;
  247.  
  248.     if(empty($avia_config['remove_pagination'] ))
  249.     {
  250.         echo "<div class='{$blog_style}'>".avia_pagination('', 'nav')."</div>";
  251.     }
  252. ?>
Advertisement
Add Comment
Please, Sign In to add comment