PageRenderTime 57ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Project/faci-qsoft/wp-content/themes/Avada/templates/blog-layout.php

https://gitlab.com/hop23typhu/list-theme
PHP | 281 lines | 192 code | 42 blank | 47 comment | 97 complexity | 8396fdb4c1a9aa2732801b2516fe2e87 MD5 | raw file
  1. <?php
  2. /**
  3. * Render the blog layouts
  4. *
  5. * @author ThemeFusion
  6. * @package Avada/Templates
  7. * @version 1.0
  8. */
  9. // Do not allow directly accessing this file
  10. if ( ! defined( 'ABSPATH' ) ) exit( 'Direct script access denied.' );
  11. global $wp_query;
  12. // Set the correct post container layout classes
  13. $blog_layout = avada_get_blog_layout();
  14. $post_class = sprintf( 'fusion-post-%s', $blog_layout );
  15. if ( $blog_layout == 'grid' ) {
  16. $container_class = sprintf( 'fusion-blog-layout-%s fusion-blog-layout-%s-%s isotope ', $blog_layout, $blog_layout, Avada()->settings->get( 'blog_grid_columns' ) );
  17. } else {
  18. $container_class = sprintf( 'fusion-blog-layout-%s ', $blog_layout );
  19. }
  20. // Set class for scrolling type
  21. if ( Avada()->settings->get( 'blog_pagination_type' ) == 'Infinite Scroll' ||
  22. Avada()->settings->get( 'blog_pagination_type' ) == 'load_more_button'
  23. ) {
  24. $container_class .= 'fusion-blog-infinite fusion-posts-container-infinite ';
  25. } else {
  26. $container_class .= 'fusion-blog-pagination ';
  27. }
  28. if ( ! Avada()->settings->get( 'featured_images' ) ) {
  29. $container_class .= 'fusion-blog-no-images ';
  30. }
  31. // Add the timeline icon
  32. if ( $blog_layout == 'timeline' ) {
  33. echo '<div class="fusion-timeline-icon"><i class="fusion-icon-bubbles"></i></div>';
  34. }
  35. if ( is_search() &&
  36. Avada()->settings->get( 'search_results_per_page' )
  37. ) {
  38. $number_of_pages = ceil( $wp_query->found_posts / Avada()->settings->get( 'search_results_per_page' ) );
  39. } else {
  40. $number_of_pages = $wp_query->max_num_pages;
  41. }
  42. echo sprintf( '<div id="posts-container" class="%sfusion-blog-archive fusion-clearfix" data-pages="%s">', $container_class, $number_of_pages );
  43. if( $blog_layout == 'timeline' ) {
  44. // Initialize the time stamps for timeline month/year check
  45. $post_count = 1;
  46. $prev_post_timestamp = null;
  47. $prev_post_month = null;
  48. $prev_post_year = null;
  49. $first_timeline_loop = false;
  50. // Add the container that holds the actual timeline line
  51. echo '<div class="fusion-timeline-line"></div>';
  52. }
  53. // Start the main loop
  54. while ( have_posts() ): the_post();
  55. // Set the time stamps for timeline month/year check
  56. $alignment_class = '';
  57. if( $blog_layout == 'timeline' ) {
  58. $post_timestamp = get_the_time( 'U' );
  59. $post_month = date( 'n', $post_timestamp );
  60. $post_year = get_the_date( 'Y' );
  61. $current_date = get_the_date( 'Y-n' );
  62. // Set the correct column class for every post
  63. if( $post_count % 2 ) {
  64. $alignment_class = 'fusion-left-column';
  65. } else {
  66. $alignment_class = 'fusion-right-column';
  67. }
  68. // Set the timeline month label
  69. if ( $prev_post_month != $post_month ||
  70. $prev_post_year != $post_year
  71. ) {
  72. if( $post_count > 1 ) {
  73. echo '</div>';
  74. }
  75. echo sprintf( '<h3 class="fusion-timeline-date">%s</h3>', get_the_date( Avada()->settings->get( 'timeline_date_format' ) ) );
  76. echo '<div class="fusion-collapse-month">';
  77. }
  78. }
  79. // Set the has-post-thumbnail if a video is used. This is needed if no featured image is present.
  80. $thumb_class = '';
  81. if ( get_post_meta( get_the_ID(), 'pyre_video', true ) ) {
  82. $thumb_class = ' has-post-thumbnail';
  83. }
  84. $post_classes = sprintf( '%s %s %s post fusion-clearfix', $post_class, $alignment_class, $thumb_class );
  85. ob_start();
  86. post_class( $post_classes );
  87. $post_classes = ob_get_clean();
  88. echo sprintf( '<div id="post-%s" %s>', get_the_ID(), $post_classes );
  89. // Add an additional wrapper for grid layout border
  90. if ( $blog_layout == 'grid' ) {
  91. echo '<div class="fusion-post-wrapper">';
  92. }
  93. // Get featured images for all but large-alternate layout
  94. if ( ( ( is_search() && ! Avada()->settings->get( 'search_featured_images' ) ) || ( ! is_search() && Avada()->settings->get( 'featured_images' ) ) ) &&
  95. $blog_layout == 'large-alternate'
  96. ) {
  97. get_template_part( 'new-slideshow' );
  98. }
  99. // Get the post date and format box for alternate layouts
  100. if ( $blog_layout == 'large-alternate' ||
  101. $blog_layout == 'medium-alternate'
  102. ) {
  103. echo '<div class="fusion-date-and-formats">';
  104. /**
  105. * avada_blog_post_date_adn_format hook
  106. *
  107. * @hooked avada_render_blog_post_date - 10 (outputs the HTML for the date box)
  108. * @hooked avada_render_blog_post_format - 15 (outputs the HTML for the post format box)
  109. */
  110. do_action( 'avada_blog_post_date_and_format' );
  111. echo '</div>';
  112. }
  113. // Get featured images for all but large-alternate layout
  114. if ( ( ( is_search() && ! Avada()->settings->get( 'search_featured_images' ) ) || ( ! is_search() && Avada()->settings->get( 'featured_images' ) ) ) &&
  115. $blog_layout != 'large-alternate'
  116. ) {
  117. get_template_part( 'new-slideshow' );
  118. }
  119. // post-content-wrapper only needed for grid and timeline
  120. if ( $blog_layout == 'grid' ||
  121. $blog_layout == 'timeline'
  122. ) {
  123. echo '<div class="fusion-post-content-wrapper">';
  124. }
  125. // Add the circles for timeline layout
  126. if ( $blog_layout == 'timeline' ) {
  127. echo '<div class="fusion-timeline-circle"></div>';
  128. echo '<div class="fusion-timeline-arrow"></div>';
  129. }
  130. echo '<div class="fusion-post-content post-content">';
  131. // Render the post title
  132. echo avada_render_post_title( get_the_ID() );
  133. // Render post meta for grid and timeline layouts
  134. if ( $blog_layout == 'grid' ||
  135. $blog_layout == 'timeline'
  136. ) {
  137. echo avada_render_post_metadata( 'grid_timeline' );
  138. if ( ( Avada()->settings->get( 'post_meta' ) && ( ! Avada()->settings->get( 'post_meta_author' ) || ! Avada()->settings->get( 'post_meta_date' ) || ! Avada()->settings->get( 'post_meta_cats' ) || ! Avada()->settings->get( 'post_meta_tags' ) || ! Avada()->settings->get( 'post_meta_comments' ) || ! Avada()->settings->get( 'post_meta_read' ) ) ) &&
  139. Avada()->settings->get( 'excerpt_length_blog' ) > 0
  140. ) {
  141. echo '<div class="fusion-content-sep"></div>';
  142. }
  143. // Render post meta for alternate layouts
  144. } elseif( $blog_layout == 'large-alternate' ||
  145. $blog_layout == 'medium-alternate'
  146. ) {
  147. echo avada_render_post_metadata( 'alternate' );
  148. }
  149. echo '<div class="fusion-post-content-container">';
  150. /**
  151. * avada_blog_post_content hook
  152. *
  153. * @hooked avada_render_blog_post_content - 10 (outputs the post content wrapped with a container)
  154. */
  155. do_action( 'avada_blog_post_content' );
  156. echo '</div>';
  157. echo '</div>'; // end post-content
  158. if( $blog_layout == 'medium' ||
  159. $blog_layout == 'medium-alternate'
  160. ) {
  161. echo '<div class="fusion-clearfix"></div>';
  162. }
  163. // Render post meta data according to layout
  164. if ( ( Avada()->settings->get( 'post_meta' ) && ( ! Avada()->settings->get( 'post_meta_author' ) || ! Avada()->settings->get( 'post_meta_date' ) || ! Avada()->settings->get( 'post_meta_cats' ) || ! Avada()->settings->get( 'post_meta_tags' ) || ! Avada()->settings->get( 'post_meta_comments' ) || ! Avada()->settings->get( 'post_meta_read' ) ) ) ) {
  165. echo '<div class="fusion-meta-info">';
  166. if ( $blog_layout == 'grid' ||
  167. $blog_layout == 'timeline'
  168. ) {
  169. // Render read more for grid/timeline layouts
  170. echo '<div class="fusion-alignleft">';
  171. if ( ! Avada()->settings->get( 'post_meta_read' ) ) {
  172. $link_target = '';
  173. if( fusion_get_page_option( 'link_icon_target', get_the_ID() ) == 'yes' ||
  174. fusion_get_page_option( 'post_links_target', get_the_ID() ) == 'yes' ) {
  175. $link_target = ' target="_blank"';
  176. }
  177. echo sprintf( '<a href="%s" class="fusion-read-more"%s>%s</a>', get_permalink(), $link_target, apply_filters( 'avada_blog_read_more_link', __( 'Read More', 'Avada' ) ) );
  178. }
  179. echo '</div>';
  180. // Render comments for grid/timeline layouts
  181. echo '<div class="fusion-alignright">';
  182. if ( ! Avada()->settings->get( 'post_meta_comments' ) ) {
  183. if( ! post_password_required( get_the_ID() ) ) {
  184. comments_popup_link('<i class="fusion-icon-bubbles"></i>&nbsp;' . __( '0', 'Avada' ), '<i class="fusion-icon-bubbles"></i>&nbsp;' . __( '1', 'Avada' ), '<i class="fusion-icon-bubbles"></i>&nbsp;' . '%' );
  185. } else {
  186. echo sprintf( '<i class="fusion-icon-bubbles"></i>&nbsp;%s', __( 'Protected', 'Avada' ) );
  187. }
  188. }
  189. echo '</div>';
  190. } else {
  191. // Render all meta data for medium and large layouts
  192. if ( $blog_layout == 'large' || $blog_layout == 'medium' ) {
  193. echo avada_render_post_metadata( 'standard' );
  194. }
  195. // Render read more for medium/large and medium/large alternate layouts
  196. echo '<div class="fusion-alignright">';
  197. if ( ! Avada()->settings->get( 'post_meta_read' ) ) {
  198. $link_target = '';
  199. if( fusion_get_page_option( 'link_icon_target', get_the_ID() ) == 'yes' ||
  200. fusion_get_page_option( 'post_links_target', get_the_ID() ) == 'yes' ) {
  201. $link_target = ' target="_blank"';
  202. }
  203. echo sprintf( '<a href="%s" class="fusion-read-more"%s>%s</a>', get_permalink(), $link_target, apply_filters( 'avada_read_more_name', __( 'Read More', 'Avada' ) ) );
  204. }
  205. echo '</div>';
  206. }
  207. echo '</div>'; // end meta-info
  208. }
  209. if ( $blog_layout == 'grid' ||
  210. $blog_layout == 'timeline'
  211. ) {
  212. echo '</div>'; // end post-content-wrapper
  213. }
  214. if ( $blog_layout == 'grid' ) {
  215. echo '</div>'; // end post-wrapper
  216. }
  217. echo '</div>'; // end post
  218. // Adjust the timestamp settings for next loop
  219. if ( $blog_layout == 'timeline' ) {
  220. $prev_post_timestamp = $post_timestamp;
  221. $prev_post_month = $post_month;
  222. $prev_post_year = $post_year;
  223. $post_count++;
  224. }
  225. endwhile; // end have_posts()
  226. if ( $blog_layout == 'timeline' &&
  227. $post_count > 1
  228. ) {
  229. echo '</div>';
  230. }
  231. echo '</div>'; // end posts-container
  232. // If infinite scroll with "load more" button is used
  233. if ( Avada()->settings->get( 'blog_pagination_type' ) == 'load_more_button' ) {
  234. echo sprintf( '<div class="fusion-load-more-button fusion-clearfix">%s</div>', apply_filters( 'avada_load_more_posts_name', __( 'Load More Posts', 'Avada' ) ) );
  235. }
  236. // Get the pagination
  237. fusion_pagination( $pages = '', $range = 2 );
  238. wp_reset_query();
  239. // Omit closing PHP tag to avoid "Headers already sent" issues.