Advertisement
Guest User

loop-index.php

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