$tax, 'hide_empty' => true, 'hierarchical' => false, 'parent' => $parent_term_id, ]); if (!count($terms)) { return []; } $els = []; foreach ($terms as $term) { $selected_attr = $selected_cat == $term->term_id ? 'selected' : ''; $prefix = '   '; for ($i=0; $i < $level; $i++) { $prefix .= '   '; } $els[] = blocksy_html_tag( 'option', [ 'value' => $tax . ':' . $term->term_id, $selected_attr => $selected_attr ], $prefix . $term->name ); $children = get_terms([ 'taxonomy' => $tax, 'hide_empty' => true, 'hierarchical' => false, 'parent' => $term->term_id, ]); if (count($children)) { $els = array_merge( $els, blocksy_reqursive_taxonomy($tax, $term->term_id, $level + 1, $selected_cat) ); } } return $els; } } $placeholder = esc_attr_x('Search', 'placeholder', 'blocksy'); if (isset($args['search_placeholder'])) { $placeholder = $args['search_placeholder']; } if (isset($args['ct_product_price'])) { $show_product_price = $args['ct_product_price']; } else { $show_product_price = blocksy_get_theme_mod('searchProductPrice', 'no') === 'yes'; } if (isset($args['ct_product_status'])) { $show_product_status = $args['ct_product_status']; } else { $show_product_status = blocksy_get_theme_mod('searchProductPrice', 'no') === 'yes'; } if (isset($args['search_live_results'])) { $has_live_results = $args['search_live_results']; } else { $has_live_results = blocksy_get_theme_mod('search_enable_live_results', 'yes'); } $search_live_results_output = ''; if ($has_live_results === 'yes') { if (! isset($args['live_results_attr'])) { $args['live_results_attr'] = 'thumbs'; } $live_results_attr = !empty($args['live_results_attr']) ? [$args['live_results_attr']] : []; if ($show_product_price) { array_push($live_results_attr, 'product_price'); } if ($show_product_status) { array_push($live_results_attr, 'product_status'); } $search_live_results_output = 'data-live-results="' . implode(':', $live_results_attr) . '"'; } $class_output = ''; $any = []; if (get_query_var('post_type') && ! is_array(get_query_var('post_type'))) { $any = explode(':', get_query_var('post_type')); } if ( isset($_GET['ct_post_type']) && $_GET['ct_post_type'] ) { $any = explode(':', $_GET['ct_post_type']); } if ( isset($args['ct_post_type']) && $args['ct_post_type'] ) { $any = $args['ct_post_type']; } if ( isset($args['enable_search_field_class']) && $args['enable_search_field_class'] ) { $class_output = 'class="modal-field"'; } $home_url = home_url('/'); $icon = apply_filters( 'blocksy:search-form:icon', '' ); if (isset($args['icon'])) { $icon = $args['icon']; } $has_taxonomy_filter = false; if ( isset($args['has_taxonomy_filter']) ) { $selected_cat = 0; if ( isset($_GET['ct_tax_query']) && !empty($_GET['ct_tax_query']) ) { $tax_params = explode(':', $_GET['ct_tax_query']); $selected_cat = $tax_params[1]; } $has_taxonomy_filter = $args['has_taxonomy_filter']; } if ($has_taxonomy_filter) { $options = []; $options[] = blocksy_html_tag( 'option', [ 'value' => '', ], blocksy_akg('taxonomy_filter_label', $args, __('Select Category', 'blocksy')) ); $skip_tax = [ 'product_brands' ]; $taxonomy_filter_visibility = ' ' . blocksy_visibility_classes( blocksy_akg( 'taxonomy_filter_visibility', $args, [ 'desktop' => true, 'tablet' => true, 'mobile' => false, ] ) ); foreach ($any as $post_type) { $terms_els = []; $taxonomy_names = get_taxonomies([ 'object_type' => [$post_type], 'hierarchical' => true ]); if ( ! count($taxonomy_names) ) { continue; } $has_taxonomy_children = blocksy_akg('has_taxonomy_children', $args, true); foreach ($taxonomy_names as $tax) { if ( in_array($tax, $skip_tax) ) { continue; } $terms_args = [ 'taxonomy' => $tax, 'hide_empty' => true, 'hierarchical' => false, 'parent' => 0 ]; $terms = get_terms($terms_args); if ( ! count($terms) ) { continue; } foreach ($terms as $term) { $terms_els[] = blocksy_html_tag( 'option', array_merge( [ 'value' => $tax . ':' . $term->term_id, ], $selected_cat == $term->term_id ? ['selected' => 'selected'] : [] ), $term->name ); if ($has_taxonomy_children) { $terms_els = array_merge( $terms_els, blocksy_reqursive_taxonomy($tax, $term->term_id, 0, $selected_cat) ); } } if ( ! empty($terms_els) ) { if (count($any) === 1) { $options[] = join('', $terms_els); } else { $options[] = blocksy_html_tag( 'optgroup', [ 'value' => $post_type, 'label' => get_post_type_object($post_type)->labels->name ], join('', $terms_els) ); } } } } } $html_atts = [ 'data-form-controls' => 'inside', 'data-taxonomy-filter' => 'false', 'data-submit-button' => 'icon' ]; if (isset($args['html_atts'])) { $html_atts = array_merge( $html_atts, $args['html_atts'] ); } if (! isset($args['button_type'])) { $args['button_type'] = $html_atts['data-form-controls'] . ':' . $html_atts['data-submit-button']; } if (isset($args['override_html_atts'])) { $html_atts = $args['override_html_atts']; } $button_html_atts = array_merge( [ 'data-button' => $args['button_type'], 'aria-label' => __('Search button', 'blocksy') ], isset($args['button_html_atts']) ? $args['button_html_atts'] : [] ) ?>