Advertisement
Guest User

Single Post

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