PluginProbe
Themify Builder / trunk
Themify Builder vtrunk
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / themify / includes / filter.php

filter.php in Themify Builder trunk, at themify/includes/filter.php

105 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Partial template that displays an entry filter.
4 *
5 * Created by themify
6 * @since 1.0.0
7 */
8 if(!isset($args['query_category'])){
9 return;
10 }
11 $taxonomy=empty( $args['query_taxonomy'] ) ? 'category' : $args['query_taxonomy'];
12 $cat_args=[
13 'hide_title_if_empty'=>true,
14 'show_option_none'=>false,
15 'echo'=>false,
16 'hierarchical'=>false,
17 'show_count'=>false,
18 'title_li'=>'',
19 'include'=>$args['query_category']==='0'?[]:(is_array( $args['query_category'] ) ? $args['query_category']:explode( ',',$args['query_category'] )),
20 'taxonomy'=>$taxonomy,
21 'orderby' => isset( $args['tax_orderby'] ) ? $args['tax_orderby'] : 'name',
22 'order' => isset( $args['tax_order'] ) ? $args['tax_order'] : 'descend'
23 ];
24 $cat_filter = !empty($args['ajax_filter_include']) ? 'include' : 'exclude';
25 if(!empty( $args['ajax_filter_'.$cat_filter] ) ){
26 if($cat_filter==='exclude'){
27 $cat_args['exclude']=$args['ajax_filter_'.$cat_filter];
28 unset($cat_args['include']);
29 }else{
30 foreach(explode( ',',$args['ajax_filter_'.$cat_filter] ) as $v){
31 $v=(int)$v;
32 if($v>0){
33 $cat_args['include'][]=$v;
34 }
35 }
36 }
37 }
38 if(is_category() && themify_check( 'setting-filter-category',true )){
39 $category=get_queried_object();
40 if(!empty( $category )){
41 $cat_args['child_of']=$category->term_id;
42 }
43 }
44 $list_categories=wp_list_categories( $cat_args );
45 if(!empty( $list_categories )){
46 $attrs='';
47 if(isset( $args['hash_tag'] )){
48 $list_categories=preg_replace( '/cat-item-(\d+)"/','$0 data-id="'.$args['el_id'].':$1"',$list_categories );
49 $attrs.=' data-hash="'.esc_attr( $args['el_id'] ).'"';
50 }
51 if(!has_filter( 'post_class','themify_post_filter_class' )){
52 //add category id class in post loop for masonry filter
53 add_filter( 'post_class','themify_post_filter_class',10,3 );
54 }
55 Themify_Enqueue_Assets::preFetchMasonry();
56 Themify_Enqueue_Assets::add_css( 'tf_post_filter',Themify_Enqueue_Assets::THEMIFY_CSS_MODULES_URI.'post-filter.css',null,THEMIFY_VERSION );
57 if(themify_is_themify_theme() && Themify_Enqueue_Assets::has_theme_support_css( 'post-filter' )){
58 Themify_Enqueue_Assets::loadThemeStyleModule( 'post-filter' );
59 }
60 if(isset( $args['ajax_filter'] )){
61 $ajax_filter_next_page = isset( $args['ajax_filter_paged'] ) ? ( (int) $args['ajax_filter_paged'] + 1 ) : 2;
62 $attrs.=' data-id="'.esc_attr( $args['ajax_filter_id'] ).'" data-el="'.esc_attr( $args['el_id'] ).'" data-limit="'.esc_attr( $args['ajax_filter_limit'] ).'" data-ajax="1"';
63 if(isset( $args['ajax_sort'] )){
64 $attrs.=' data-sort="true"';
65 }
66 $attrs.=' data-taxonomy="'.esc_attr( $taxonomy ).'"';
67 }
68 ?>
69 <ul class="post-filter tf_textc"<?php echo $attrs ?> data-post_type="<?php echo esc_attr( isset( $args['post_type'] ) ? $args['post_type'] : 'post' ); ?>">
70 <?php echo $list_categories ?>
71 <?php if ( isset( $args['ajax_sort'] ) ) : ?>
72 <li data-init="1" data-p="<?php echo esc_attr( $ajax_filter_next_page ); ?>" class="cat-item cat-item-all active"><?php _e( 'All','themify' ) ?></li>
73 <li class="tf_ajax_sort tf_rel">
74 <a href="#" tabindex="-1" class="tf_ajax_sort_icon"><?php echo themify_get_icon( 'menu-alt','ti',false,false,array('aria-label'=>__( 'sort','themify' )) ); ?></a>
75 <div class="tf_ajax_sort_dropdown tf_abs tf_hide tf_box">
76 <div class="tf_ajax_sort_title">
77 <span><?php _e( 'Sort by:','themify' ); ?></span>
78 <div>
79 <span class="tf_ajax_sort_order tf_inline_b tf_vmiddle<?php echo 'asc'===$args['ajax_sort_order'] ? ' active' : ''; ?>" data-type="asc"><?php echo themify_get_icon( 'arrow-up','ti',false,false,array('aria-label'=>__( 'sort','themify' )) ); ?></span>
80 <span class="tf_ajax_sort_order tf_inline_b tf_vmiddle<?php echo 'desc'===$args['ajax_sort_order'] ? ' active' : ''; ?>" data-type="desc"><?php echo themify_get_icon( 'arrow-down','ti',false,false,array('aria-label'=>__( 'sort','themify' )) ); ?></span>
81 </div>
82 </div>
83 <ul class="tf_ajax_sort_order_by tf_textl">
84 <?php
85 $orders=array(
86 'date'=>__( 'Date','themify' ),
87 'title'=>__( 'Title','themify' )
88 );
89 if(isset( $args['ajax_filter_wc'] )){
90 $orders['price']=__( 'Price','themify' );
91 $orders['rate']=__( 'Rating','themify' );
92 }
93 foreach($orders as $order=>$title):?>
94 <li data-order-by="<?php echo esc_attr( $order ); ?>"<?php echo $order===$args['ajax_sort_order_by'] ? ' class="active"' : ''; ?>><?php echo esc_html( $title ); ?></li>
95 <?php endforeach; ?>
96 </ul>
97 </div>
98 </li>
99 <?php elseif ( isset( $args['ajax_filter'] ) ) : ?>
100 <li data-init="1" data-p="<?php echo esc_attr( $ajax_filter_next_page ); ?>" class="cat-item cat-item-all active"><?php _e( 'All', 'themify' ); ?></li>
101 <?php endif; ?>
102 </ul>
103 <?php
104 }
105