Advertisement
Guest User

Untitled

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