rdusnr

Untitled

Nov 1st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5.  
  6. /**
  7. * Shortcode attributes
  8. * @var $atts
  9. * @var $title
  10. * @var $grid_columns_count
  11. * @var $grid_teasers_count
  12. * @var $grid_layout
  13. * @var $grid_link_target
  14. * @var $filter
  15. * @var $grid_thumb_size
  16. * @var $grid_layout_mode
  17. * @var $el_class
  18. * @var $loop
  19. * @var $content - shortcode content
  20. * Shortcode class
  21. * @var $this WPBakeryShortCode_VC_Posts_Grid
  22. */
  23. $title = $grid_columns_count = $grid_teasers_count = $grid_layout =
  24. $grid_link_target = $filter = $grid_thumb_size = $grid_layout_mode = $el_class = $loop = '';
  25.  
  26.  
  27. /* KLEO Added */
  28. global $kleo_config;
  29. $post_layout = $query_offset = $show_thumb = $inline_meta = $show_footer = $load_more = $ajax_post = $ajax_paged = '';
  30. /* END KLEO Added */
  31.  
  32.  
  33. global $vc_teaser_box;
  34. $grid_link = '';
  35. $posts = array();
  36. $atts = vc_map_get_attributes( $this->getShortcode(), $atts );
  37. extract( $atts );
  38.  
  39. if ( empty( $loop ) ) {
  40. return;
  41. }
  42. $this->getLoop( $loop );
  43. $my_query = $this->query;
  44. $args = $this->loop_args;
  45.  
  46. if ( (int) $query_offset > 0 ) {
  47. $args['offset'] = $query_offset;
  48. }
  49.  
  50.  
  51. /* Set the global post from the sent AJAX request */
  52. if ( '' != $ajax_post ) {
  53. $page_post_id = $ajax_post;
  54. } else {
  55. $page_post_id = get_the_ID();
  56. }
  57.  
  58. /* check if we have pagination */
  59. if ( '' != $load_more ) {
  60. global $sq_posts_count;
  61. $sq_posts_count++;
  62.  
  63. set_transient( 'kleo_post_' . $page_post_id . '_' . $sq_posts_count, $atts );
  64.  
  65. /* if we get a page over ajax request */
  66. if ( '' != $ajax_paged ) {
  67. $args['paged'] = $ajax_paged;
  68. }
  69.  
  70. } else {
  71. $sq_posts_count = 0;
  72. }
  73.  
  74. $el_class = $el_class != "" ? " " . $el_class : "";
  75.  
  76. // Alias for Grid to Masonry
  77. if ( $post_layout == 'grid' ) {
  78. $post_layout = 'masonry';
  79. }
  80. $post_layout = apply_filters( 'kleo_blog_type', $post_layout, $page_post_id );
  81.  
  82. if ( $post_layout == 'standard' && 0 === strpos( $show_thumb, 'just_' ) ) {
  83. global $conditional_thumb;
  84. $conditional_thumb = substr( $show_thumb, - 1 );
  85. $el_class .= ' just-thumb-' . $conditional_thumb;
  86. } elseif ( $show_thumb == 'no' ) {
  87. global $conditional_thumb;
  88. $conditional_thumb = 0;
  89. }
  90.  
  91. if ( $show_meta == 'yes' ) {
  92. $el_class .= ' with-meta';
  93. } else {
  94. $el_class .= ' no-meta';
  95. }
  96.  
  97. if ( $show_footer == 'no' ) {
  98. $el_class .= ' no-footer';
  99. }
  100.  
  101. if ( $show_excerpt == 'no' ) {
  102. $el_class .= ' no-excerpt';
  103. }
  104.  
  105. if ( $inline_meta == 'yes' ) {
  106. $el_class .= ' inline-meta';
  107. }
  108.  
  109. $el_class .= " " . $post_layout . '-listing';
  110.  
  111. $the_query = new WP_Query( $args );
  112.  
  113. $current_page = 1;
  114. if ( '' != $ajax_paged ) {
  115. $current_page = $ajax_paged;
  116. }
  117. $next_page = $current_page + 1;
  118.  
  119. if ( $the_query->have_posts() ) : ?>
  120.  
  121. <?php
  122. //echo post data
  123. $posts_data = '<div class="sq-posts-data" style="display: none;">';
  124. $posts_data .= wp_nonce_field( 'kleo-ajax-posts-nonce', 'post-security', true, false );
  125. $posts_data .= '<input type="hidden" name="pitem" value="' . $sq_posts_count . '">';
  126. $posts_data .= '<input type="hidden" name="post_id" value="' . $page_post_id . '">';
  127. $posts_data .= '</div>';
  128.  
  129. echo $posts_data;
  130. ?>
  131.  
  132. <?php if ( $show_switcher == 'yes' && ! empty( $switcher_layouts ) ) : ?>
  133.  
  134. <?php
  135. if ( ! is_array( $switcher_layouts ) ) {
  136. $switcher_layouts = explode( ',', $switcher_layouts );
  137. }
  138. kleo_view_switch( $switcher_layouts, $post_layout, $page_post_id );
  139. ?>
  140.  
  141. <?php endif; ?>
  142.  
  143. <?php if ( $post_layout == 'masonry' ) : ?>
  144.  
  145. <div class="posts-listing responsive-cols kleo-masonry per-row-<?php echo $columns; ?><?php echo $el_class; ?>">
  146.  
  147. <?php else: ?>
  148.  
  149. <div class="posts-listing <?php echo $el_class; ?>">
  150.  
  151. <?php endif; ?>
  152.  
  153. <?php
  154. while ( $the_query->have_posts() ) : $the_query->the_post();
  155.  
  156. if ( $post_layout != 'standard' ) {
  157. get_template_part( 'page-parts/post-content-' . $post_layout );
  158. } else {
  159. get_template_part( 'content', get_post_format() );
  160. }
  161.  
  162. endwhile;
  163. ?>
  164.  
  165. </div> <!-- END post listing -->
  166.  
  167. <?php if ( '' != $load_more && $the_query->max_num_pages >= $next_page ) : ?>
  168. <div class="clearfix clear"></div>
  169. <div class="posts-load-more text-center">
  170. <a data-paged="<?php echo $next_page; ?>" class="btn btn-highlight style2" href="#"><?php _e('Load more', 'kleo_framework'); ?></a>
  171. </div>
  172. <?php endif; ?>
  173.  
  174. <?php
  175. endif;
  176. /* Restore original Post Data */
  177. wp_reset_postdata();
Add Comment
Please, Sign In to add comment