| 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 |
$placeholder = esc_html__($placeholder,'wpdirectorykit'); |
| 19 |
|
| 20 |
$filter_ids = array(); |
| 21 |
if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) { |
| 22 |
$field_value = intval($predefinedfields_query[$field_key]); |
| 23 |
} |
| 24 |
|
| 25 |
if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_category_root'])) { |
| 26 |
$custom_field_value = intval($predefinedfields_query['custom_category_root']); |
| 27 |
global $Winter_MVC_WDK; |
| 28 |
$Winter_MVC_WDK->load_helper('listing'); |
| 29 |
$Winter_MVC_WDK->model('category_m'); |
| 30 |
$category = $Winter_MVC_WDK->category_m->get($custom_field_value, TRUE); |
| 31 |
|
| 32 |
/* if root search childs */ |
| 33 |
if($category) { |
| 34 |
$filter_ids = wdk_category_get_all_childs($custom_field_value); |
| 35 |
if(!empty($filter_ids)) { |
| 36 |
if(in_array($field_value, $filter_ids) === FALSE) { |
| 37 |
$field_value = $custom_field_value; |
| 38 |
} |
| 39 |
} |
| 40 |
} else { |
| 41 |
/* category missing */ |
| 42 |
$custom_field_value = null; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
if(isset($_GET[$field_key])) { |
| 47 |
$field_value = ($_GET[$field_key]); |
| 48 |
} |
| 49 |
|
| 50 |
$hide_fields = ''; |
| 51 |
if(wmvc_show_data('search_type_tree_hide', $field_data)) { |
| 52 |
$hide_fields = wmvc_show_data('search_type_tree_hide', $field_data); |
| 53 |
} |
| 54 |
|
| 55 |
wdk_search_fields_toggle(); |
| 56 |
?> |
| 57 |
|
| 58 |
<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)); ?>"> |
| 59 |
<label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 60 |
<div class="wdk-field-group"> |
| 61 |
<?php |
| 62 |
wp_enqueue_style( 'wdk-treefield-checkboxes'); |
| 63 |
wp_enqueue_script( 'wdk-treefield-checkboxes'); |
| 64 |
?> |
| 65 |
|
| 66 |
<?php if(isset($custom_field_value)):?> |
| 67 |
<input type="hidden" name="search_category[]" value="<?php echo esc_attr($custom_field_value);?>"> |
| 68 |
<?php endif;?> |
| 69 |
<?php echo wdk_treefield_option_checkboxes ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids, FALSE, '', $hide_fields);?> |
| 70 |
</div> |
| 71 |
</div> |