[ 'meta' => 'abpet_category', 'request' => 'cat_id', 'constant' => defined( 'ABPET_Category' ) ? ABPET_Category : [], 'label' => ABPET_Function::category_label(), ], 'location' => [ 'meta' => 'abpet_location', 'request' => 'loc_id', 'constant' => defined( 'ABPET_Location' ) ? ABPET_Location : [], 'label' => ABPET_Function::location_label(), ], 'organizer' => [ 'meta' => 'abpet_organizer', 'request' => 'organizer_id', 'constant' => defined( 'ABPET_Organizer' ) ? ABPET_Organizer : [], 'label' => ABPET_Function::organizer_label(), ], 'brand' => [ 'meta' => 'abpet_brand', 'request' => 'brand_id', 'constant' => defined( 'ABPET_Brand' ) ? ABPET_Brand : [], 'label' => ABPET_Function::brand_label(), ], 'speaker' => [ 'meta' => 'speaker', 'request' => 'speaker_id', 'constant' => defined( 'ABPET_Speaker' ) ? ABPET_Speaker : [], 'label' => ABPET_Function::speaker_label(), ], ]; // The shortcode `filter` attribute decides which dropdowns may render; // the global Feature ON/OFF switches can always remove one. $filter_keys = $params['filter_taxonomies'] ?? array_keys( $taxonomies ); $filter_keys = is_array( $filter_keys ) ? array_map( 'sanitize_key', $filter_keys ) : []; $lists = []; foreach ( $taxonomies as $key => $data ) { if ( ! in_array( $key, $filter_keys, true ) || ! ABPET_Function::on_off( $key ) ) { continue; } // A shortcode that already pins this taxonomy to one term needs no dropdown. if ( ! empty( $params[ $data['request'] ] ) ) { continue; } $term_ids = []; if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { foreach ( $post_ids as $post_id ) { $value = ABPET_Function::get_post_info( $post_id, $data['meta'] ); if ( empty( $value ) ) { continue; } foreach ( explode( ',', (string) $value ) as $term_id ) { $term_id = trim( $term_id ); if ( '' !== $term_id ) { $term_ids[] = $term_id; } } } } $lists[ $key ] = array_values( array_unique( $term_ids ) ); } $has_select = false; foreach ( $lists as $term_ids ) { if ( count( $term_ids ) > 1 ) { $has_select = true; break; } } $show_toggle = $style === 'grid' || $style === 'list'; // Nothing to filter and no view switch means there is no bar to render. if ( ! $has_select && ! $show_toggle ) { return; } ?>