├── admin-taxonomy-filter.php ├── inc ├── controller.php └── settings.php └── readme.txt /admin-taxonomy-filter.php: -------------------------------------------------------------------------------- 1 | post_type = $post_type; 19 | $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 20 | $taxonomies = array_filter( $taxonomies, array( $this, 'is_filterable' ) ); 21 | array_walk( $taxonomies, array( $this, 'output_filter_for' ) ); 22 | } 23 | 24 | /** 25 | * Check if we have some taxonomies to filter. 26 | * 27 | * @param \WP_Taxonomy $taxonomy The taxonomy object. 28 | * 29 | * @return bool 30 | */ 31 | protected function is_filterable( $taxonomy ) { 32 | // Post category is filterable by default. 33 | if ( 'post' === $this->post_type && 'category' === $taxonomy->name ) { 34 | return false; 35 | } 36 | 37 | $option = get_option( 'admin_taxonomy_filter' ); 38 | return isset( $option[ $this->post_type ] ) && in_array( $taxonomy->name, (array) $option[ $this->post_type ], true ); 39 | } 40 | 41 | /** 42 | * Output filter for a taxonomy. 43 | * 44 | * @param \WP_Taxonomy $taxonomy The taxonomy object. 45 | */ 46 | protected function output_filter_for( $taxonomy ) { 47 | $selected = (string) filter_input( INPUT_GET, $taxonomy->query_var ); 48 | wp_dropdown_categories( array( 49 | 'show_option_all' => sprintf( __( 'All %s', 'admin-taxonomy-filter' ), $taxonomy->label ), 50 | 'orderby' => 'name', 51 | 'order' => 'ASC', 52 | 'hide_empty' => false, 53 | 'hide_if_empty' => true, 54 | 'selected' => $selected, 55 | 'hierarchical' => true, 56 | 'name' => $taxonomy->query_var, 57 | 'taxonomy' => $taxonomy->name, 58 | 'value_field' => 'slug', 59 | ) ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /inc/settings.php: -------------------------------------------------------------------------------- 1 | 20 |
21 |

22 |
23 |
24 |
25 | 30 |
31 |
32 |
33 |

34 | 35 |

36 |
37 |

38 |

Meta Box -

39 |

Slim SEO -

40 |

Falcon -

41 |
42 |
43 |
44 |
45 |
46 |
47 | ', esc_html( $post_type_object->label ), '

'; 89 | echo ''; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Admin Taxonomy Filter === 2 | Contributors: elightup, rilwis 3 | Donate link: https://paypal.me/anhtnt 4 | Tags: taxonomy filter, post filter, admin, taxonomy, post list 5 | Requires at least: 4.3 6 | Tested up to: 6.5.3 7 | Stable tag: 1.0.4 8 | License: GPLv2 or later 9 | 10 | Filter posts or custom post types in the admin area by custom taxonomies. 11 | 12 | == Description == 13 | 14 | **Admin Taxonomy Filter** helps you to filter posts or custom post types in the admin area (the post list table) by custom taxonomies. It's similar to filter posts by categories, which is supported by default. 15 | 16 | The plugin supports filter by multiple taxonomies and has settings to let you choose which taxonomies are filterable. 17 | 18 | The plugin is open source and hosted on [Github](https://github.com/rilwis/admin-taxonomy-filter/). If you have any problem or feedback, please open an issue. 19 | 20 | ### You might also like 21 | 22 | If you like this plugin, you might also like our other WordPress products: 23 | 24 | - [Meta Box](https://metabox.io) - A powerful WordPress plugin for creating custom post types and custom fields. 25 | - [Slim SEO](https://wpslimseo.com) - A fast, lightweight and full-featured SEO plugin for WordPress with minimal configuration. 26 | - [Slim SEO Schema](https://wpslimseo.com/products/slim-seo-schema/) - An advanced, powerful and flexible plugin to add schemas to WordPress. 27 | - [Slim SEO Link Manager](https://wpslimseo.com/products/slim-seo-link-manager/) - Build internal link easier in WordPress with real-time reports. 28 | - [GretaThemes](https://gretathemes.com) - Free and premium WordPress themes that clean, simple and just work. 29 | - [Auto Listings](https://wpautolistings.com) - A car sale and dealership plugin for WordPress. 30 | 31 | == Installation == 32 | 33 | - Go to **Plugins | Add New** and search for **Admin Taxonomy Filter** 34 | - Click **Install Now** button to install the plugin 35 | - After installing, click **Activate Plugin** to activate the plugin 36 | 37 | After installing, go to **Settings | Taxonomy Filter** and select the taxonomies you want to filter for each custom post type. 38 | 39 | Then go to the all posts screen to see the filter above the table. 40 | 41 | == Frequently Asked Questions == 42 | 43 | == Screenshots == 44 | 1. Settings 45 | 2. Filters in action 46 | 47 | == Changelog == 48 | 49 | = 1.0.4 = 50 | - Fix deprecated notice in PHP 8.1 51 | 52 | = 1.0.3 = 53 | - Update compatibility with the latest version of WordPress 54 | 55 | = 1.0.2 = 56 | - Update compatibility tags 57 | 58 | = 1.0.1 = 59 | - Update compatibility with the latest version of WordPress 60 | 61 | = 1.0 = 62 | - First version 63 | 64 | == Upgrade Notice == 65 | --------------------------------------------------------------------------------