' ); if (isset($args['icon'])) { $icon = $args['icon']; } $allowed_post_types = []; if (get_query_var('post_type') && ! is_array(get_query_var('post_type'))) { $allowed_post_types = explode(':', get_query_var('post_type')); } if ( isset($_GET['ct_post_type']) && $_GET['ct_post_type'] ) { $allowed_post_types = explode(':', $_GET['ct_post_type']); } if ( isset($args['ct_post_type']) && $args['ct_post_type'] ) { $allowed_post_types = $args['ct_post_type']; } $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, ] ) ); if (empty($allowed_post_types)) { $allowed_post_types[] = 'post'; $allowed_post_types[] = 'page'; if (class_exists('WooCommerce')) { $allowed_post_types[] = 'product'; } $all_cpts = blocksy_manager()->post_types->get_supported_post_types(); if (function_exists('is_bbpress')) { $allowed_post_types[] = 'forum'; $allowed_post_types[] = 'topic'; $allowed_post_types[] = 'reply'; } foreach ($all_cpts as $single_cpt) { $allowed_post_types[] = $single_cpt; } } foreach ($allowed_post_types 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($allowed_post_types) === 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'] : [] ) ?>