PluginProbe
WP Directory Kit / 1.1.6
WP Directory Kit v1.1.6
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / views / search_fields / CATEGORY.php

CATEGORY.php in WP Directory Kit 1.1.6, at application/views/search_fields/CATEGORY.php

161 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Search field CATEGORY.
4 *
5 * This is the template that field layout for search form
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13 <?php
14 $field_key = 'search_category';
15 $field_attr_id = 'wdk_search_'.wmvc_show_data('idfield', $field_data);
16 $placeholder = wmvc_show_data('field_label', $field_data);
17 $field_value = '';
18
19 $filter_ids = array();
20 if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) {
21 $field_value = intval($predefinedfields_query[$field_key]);
22 }
23
24 if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_category_root'])) {
25 $custom_field_value = intval($predefinedfields_query['custom_category_root']);
26 global $Winter_MVC_WDK;
27 $Winter_MVC_WDK->load_helper('listing');
28 $Winter_MVC_WDK->model('category_m');
29 $category = $Winter_MVC_WDK->category_m->get($custom_field_value, TRUE);
30
31 /* if root search childs */
32 if(empty(wmvc_show_data('parent_id', $category, false, TRUE, TRUE))) {
33 $filter_ids = wdk_category_get_all_childs($custom_field_value);
34 if(!empty($filter_ids)) {
35 $filter_ids[] = $custom_field_value;
36
37 if(in_array($field_value, $filter_ids) === FALSE) {
38 $field_value = $custom_field_value;
39 }
40 }
41 }
42 }
43
44 if(isset($_GET[$field_key])) {
45 $field_value = ($_GET[$field_key]);
46 }
47
48 wdk_search_fields_toggle();
49 ?>
50
51 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_dropdown'):?>
52 <?php
53 global $Winter_MVC_WDK;
54 $Winter_MVC_WDK->load_helper('listing');
55 $Winter_MVC_WDK->model('category_m');
56
57 $categories = array();
58 if(!empty($field_value)) {
59 $categories[] = $field_value;
60 $category = $Winter_MVC_WDK->category_m->get($field_value, TRUE);
61
62 while(!empty($category->parent_id)) {
63 $category = $Winter_MVC_WDK->category_m->get($category->parent_id, TRUE);
64 $categories[] = $category->idcategory;
65 }
66 krsort($categories);
67 } else {
68 $categories[] = 0;
69 }
70
71 wp_enqueue_style('wdk-treefield-dropdown');
72 wp_enqueue_script('wdk-treefield-dropdown');
73 wp_enqueue_style( 'dashicons' );
74
75
76 $level_max = $Winter_MVC_WDK->category_m->get_max_level();
77
78 $placeholder = [
79 0 => esc_html__('Select Categories','wpdirectorykit'),
80 1 => esc_html__('Select Sub Categories','wpdirectorykit'),
81 2 => esc_html__('Select Sub Categories','wpdirectorykit'),
82 3 => esc_html__('Select Sub Categories','wpdirectorykit'),
83 4 => esc_html__('Select Sub Categories','wpdirectorykit'),
84 5 => esc_html__('Select Sub Categories','wpdirectorykit'),
85 ];
86
87
88 ?>
89
90 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?>">
91 <?php
92 $level = 0;
93 foreach ($categories as $category) {
94 $current = $Winter_MVC_WDK->category_m->get($category, TRUE);
95
96 $list = $Winter_MVC_WDK->category_m->get_by(array('parent_id = '.$current->parent_id => NULL));
97
98 if(isset($placeholder[$level])) {
99 $values_list = array(''=> $placeholder[$level]);
100 } else {
101 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
102 }
103
104 foreach ($list as $list_value) {
105 $values_list[$list_value->idcategory] = $list_value->category_title;
106 }
107 ?>
108
109 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk-field wdk-col wdk_treefield_dropdown <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>
110 wdk_field_id_category">
111 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
112 <div class="wdk-field-group">
113 <?php echo wmvc_select_option('category_'.$level, $values_list, $category, 'class="wdk-control"');?>
114 </div>
115 </div>
116
117 <?php
118 $level++;
119 }
120
121 if($level<$level_max ) {
122 for (; $level<$level_max;) {
123
124 if(isset($placeholder[$level])) {
125 $values_list = array(''=> $placeholder[$level]);
126 } else {
127 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
128 }
129
130 ?>
131
132 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk-field wdk-col wdk_treefield_dropdown <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>">
133 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
134 <div class="wdk-field-group">
135 <?php echo wmvc_select_option('category_'.$level, $values_list, NULL, 'class="wdk-control"');?>
136 </div>
137 </div>
138
139 <?php
140 $level++;
141 }
142 }
143 ?>
144 <?php else:?>
145 <div class="wdk-field wdk-col <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>">
146 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
147 <div class="wdk-field-group">
148 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'select2'):?>
149 <?php echo wdk_treefield_select_ajax ($field_key.'[]', 'category_m', $field_value, 'category_title','idcategory', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
150 <?php elseif(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_checkboxes'):?>
151 <?php
152 wp_enqueue_style( 'wdk-treefield-checkboxes');
153 wp_enqueue_script( 'wdk-treefield-checkboxes');
154 ?>
155 <?php echo wdk_treefield_option_checkboxes ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
156 <?php else:?>
157 <?php echo wdk_treefield_option ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
158 <?php endif;?>
159 </div>
160 </div>
161 <?php endif;?>