class-activation.php
1 year ago
class-admin-menu-organizer.php
1 year ago
class-auto-publish-posts-with-missed-schedule.php
1 year ago
class-avif-upload.php
1 year ago
class-change-login-url.php
1 year ago
class-cleanup-admin-bar.php
1 year ago
class-common-methods.php
1 year ago
class-content-duplication.php
1 year ago
class-content-order.php
1 year ago
class-custom-admin-footer-text.php
1 year ago
class-custom-body-class.php
1 year ago
class-custom-css.php
1 year ago
class-custom-nav-menu-items-in-new-tab.php
1 year ago
class-deactivation.php
1 year ago
class-disable-comments.php
1 year ago
class-disable-dashboard-widgets.php
1 year ago
class-disable-feeds.php
1 year ago
class-disable-gutenberg.php
1 year ago
class-disable-rest-api.php
1 year ago
class-disable-smaller-components.php
1 year ago
class-disable-updates.php
1 year ago
class-disable-xml-rpc.php
1 year ago
class-display-system-summary.php
1 year ago
class-email-address-obfuscator.php
1 year ago
class-email-delivery.php
1 year ago
class-enhance-list-tables.php
1 year ago
class-external-permalinks.php
1 year ago
class-heartbeat-control.php
1 year ago
class-hide-admin-bar.php
1 year ago
class-hide-admin-notices.php
1 year ago
class-image-sizes-panel.php
1 year ago
class-image-upload-control.php
1 year ago
class-insert-head-body-footer-code.php
1 year ago
class-last-login-column.php
1 year ago
class-limit-login-attempts.php
1 year ago
class-login-id-type.php
1 year ago
class-login-logout-menu.php
1 year ago
class-maintenance-mode.php
1 year ago
class-manage-ads-appads-txt.php
1 year ago
class-manage-robots-txt.php
1 year ago
class-media-replacement.php
1 year ago
class-multiple-user-roles.php
1 year ago
class-obfuscate-author-slugs.php
1 year ago
class-open-external-links-in-new-tab.php
1 year ago
class-password-protection.php
1 year ago
class-redirect-after-login.php
1 year ago
class-redirect-after-logout.php
1 year ago
class-redirect-fourofour.php
1 year ago
class-revisions-control.php
1 year ago
class-search-engines-visibility.php
1 year ago
class-settings-fields-render.php
1 year ago
class-settings-sanitization.php
1 year ago
class-settings-sections-fields.php
1 year ago
class-show-custom-taxonomy-filters.php
1 year ago
class-site-identity-on-login-page.php
1 year ago
class-svg-upload.php
1 year ago
class-various-admin-ui-enhancements.php
1 year ago
class-view-admin-as-role.php
1 year ago
class-wider-admin-menu.php
1 year ago
class-wp-config-transformer.php
1 year ago
class-show-custom-taxonomy-filters.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | /** |
| 6 | * Class for Show Custom Taxonomy Filters module |
| 7 | * |
| 8 | * @since 6.9.5 |
| 9 | */ |
| 10 | class Show_Custom_Taxonomy_Filters { |
| 11 | // Excluded taxonomies |
| 12 | private $inapplicable_taxonomies = array( |
| 13 | 'category', |
| 14 | // Posts Categories |
| 15 | 'product_cat', |
| 16 | // WooCommerce Product Categories |
| 17 | 'asenha_code_snippet_category', |
| 18 | // ASE Code Snippets Categories |
| 19 | 'asenha-media-category', |
| 20 | ); |
| 21 | |
| 22 | /** |
| 23 | * Show custom (hierarchical) taxonomy filter(s) for all post types. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | public function show_custom_taxonomy_filters( $post_type ) { |
| 28 | $object_taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
| 29 | array_walk( $object_taxonomies, [$this, 'output_taxonomy_filter'] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Output filter on the post type's list table for a taxonomy |
| 34 | * |
| 35 | * @since 1.0.0 |
| 36 | */ |
| 37 | public function output_taxonomy_filter( $taxonomy ) { |
| 38 | // Show filter if taxonomy is hierarchical |
| 39 | if ( true === $taxonomy->hierarchical && !in_array( $taxonomy->name, $this->inapplicable_taxonomies ) ) { |
| 40 | $this->render_additional_filter( $taxonomy ); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Render additional filter |
| 46 | * |
| 47 | * @since 6.9.7 |
| 48 | */ |
| 49 | public function render_additional_filter( $taxonomy ) { |
| 50 | $show_option_all_label = sprintf( 'All %s', ucwords( $taxonomy->label ) ); |
| 51 | if ( property_exists( $taxonomy, 'labels' ) ) { |
| 52 | $taxonomy_labels = $taxonomy->labels; |
| 53 | if ( property_exists( $taxonomy_labels, 'all_items' ) && !empty( $taxonomy_labels->all_items ) ) { |
| 54 | $show_option_all_label = $taxonomy->labels->all_items; |
| 55 | } |
| 56 | } |
| 57 | wp_dropdown_categories( array( |
| 58 | 'show_option_all' => $show_option_all_label, |
| 59 | 'orderby' => 'name', |
| 60 | 'order' => 'ASC', |
| 61 | 'hide_empty' => false, |
| 62 | 'hide_if_empty' => true, |
| 63 | 'selected' => sanitize_text_field( ( isset( $_GET[$taxonomy->query_var] ) && !empty( $_GET[$taxonomy->query_var] ) ? sanitize_text_field( $_GET[$taxonomy->query_var] ) : '' ) ), |
| 64 | 'hierarchical' => true, |
| 65 | 'name' => $taxonomy->query_var, |
| 66 | 'taxonomy' => $taxonomy->name, |
| 67 | 'value_field' => 'slug', |
| 68 | ) ); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 |