Advertisement
palsushobhan

wcfm-store-page-article-tab-wolmart-theme

May 10th, 2024
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.25 KB | None | 0 0
  1. add_action( 'wcfmmp_before_store_article', function() {
  2.     do_action( 'wolmart_print_before_page_layout' );
  3.     echo '<div class="post-archive">';
  4. } );
  5.  
  6. add_action('wcfmmp_before_store_article_loop', function() {
  7.     global $wolmart_layout, $wp_query;
  8.  
  9.     $posts_filter = $wolmart_layout['posts_filter'];
  10.     $wrap_classes = array( 'posts' );
  11.     $wrap_attrs   = '';
  12.  
  13.     if ( isset( $_REQUEST['post_type'] ) && in_array( $_REQUEST['post_type'], array( 'list', 'mask', 'simple' ) ) ) {
  14.         $wolmart_layout['post_type'] = $_REQUEST['post_type'];
  15.     } elseif ( wolmart_doing_ajax() && ! empty( $_REQUEST['only_posts'] ) ) {
  16.         $wolmart_layout['post_type'] = '';
  17.     }
  18.     if(empty($wolmart_layout['post_type'])) {
  19.         $wolmart_layout['post_type'] = 'list';
  20.     }
  21.     $post_type = $wolmart_layout['post_type'];
  22.  
  23.     // Category Filter
  24.     if ( $posts_filter &&
  25.         ( empty( $wolmart_layout['left_sidebar'] ) || 'hide' == $wolmart_layout['left_sidebar'] ) &&
  26.         ( empty( $wolmart_layout['right_sidebar'] ) || 'hide' == $wolmart_layout['right_sidebar'] ) &&
  27.         'list' != $post_type ) {
  28.         wolmart_get_template_part( 'posts/elements/blog-filter' );
  29.     }
  30.  
  31.     // Grid or Masonry
  32.     if ( 'masonry' == $wolmart_layout['posts_layout'] ) {
  33.         $wrap_classes[] = 'grid';
  34.         $wrap_classes[] = 'masonry';
  35.         $wrap_attrs     = " data-grid-options='" . json_encode( array( 'masonry' => array( 'horizontalOrder' => true ) ) ) . "'";
  36.         wp_enqueue_script( 'isotope-pkgd' );
  37.     }
  38.  
  39.     // List or Grid
  40.     if ( 'list' == $post_type ) {
  41.         $wrap_classes[] = 'list-type-posts';
  42.         $wrap_classes[] = wolmart_get_col_class(
  43.             array(
  44.                 'md'  => 1,
  45.                 'sm'  => 1,
  46.                 'min' => 1,
  47.             )
  48.         );
  49.     } else {
  50.         $cols_cnt        = wolmart_get_responsive_cols( array( 'lg' => intval( $wolmart_layout['posts_column'] ) ) );
  51.         $cols_cnt['min'] = 1;
  52.         $wrap_classes[]  = wolmart_get_col_class( $cols_cnt );
  53.     }
  54.  
  55.     // Loadmore Button or Pagination
  56.     if ( 1 < $wp_query->max_num_pages ) {
  57.         if ( 'scroll' == $wolmart_layout['loadmore_type'] ) {
  58.             $wrap_classes[] = 'load-scroll';
  59.         }
  60.         $wrap_attrs .= ' ' . wolmart_loadmore_attributes( '', array( 'blog' => true ), 'page', $wp_query->max_num_pages );
  61.     }
  62.  
  63.     // Print Posts
  64.     $wrap_classes = apply_filters( 'wolmart_post_loop_wrapper_classes', $wrap_classes );
  65.  
  66.     echo '<div class="' . esc_attr( implode( ' ', $wrap_classes ) ) . '"' . $wrap_attrs . ( $post_type ? ' data-post-type="' . $post_type . '"' : '' ) . '>';
  67.  
  68. });
  69.  
  70. add_action( 'wcfmmp_store_article_template', function() {
  71.     wolmart_get_template_part( 'posts/post', null, array( 'single' => false ) );
  72. });
  73.  
  74. add_action( 'wcfmmp_after_store_article_loop', function( $store_id, $store_info ) {
  75.     echo '</div>';
  76. }, 50, 2);
  77.  
  78. add_action( 'wcfmmp_store_article_template_none', function() {
  79. ?>
  80.     <h2 class="entry-title"><?php esc_html_e( 'Nothing Found', 'wolmart' ); ?></h2>
  81. <?php
  82. });
  83.  
  84. add_action( 'wcfmmp_after_store_article', function() {
  85.     do_action( 'wolmart_print_after_page_layout' );
  86.     echo '</div>';
  87. } );
  88.  
  89. add_filter( 'wcfm_is_allow_store_articles', '__return_true' );
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement