├── admin-taxonomy-filter.php ├── inc ├── controller.php └── settings.php └── readme.txt /admin-taxonomy-filter.php: -------------------------------------------------------------------------------- 1 | . 27 | */ 28 | 29 | defined( 'ABSPATH' ) || die; 30 | 31 | if ( is_admin() ) { 32 | require __DIR__ . '/inc/controller.php'; 33 | require __DIR__ . '/inc/settings.php'; 34 | 35 | new ATF_Controller; 36 | new ATF_Settings; 37 | } -------------------------------------------------------------------------------- /inc/controller.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.8.3 7 | Stable tag: 1.0.5 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 | - [GretaThemes](https://gretathemes.com) - Free and premium WordPress themes that clean, simple and just work. 27 | - [Auto Listings](https://wpautolistings.com) - A car sale and dealership plugin for WordPress. 28 | 29 | == Installation == 30 | 31 | - Go to **Plugins | Add New** and search for **Admin Taxonomy Filter** 32 | - Click **Install Now** button to install the plugin 33 | - After installing, click **Activate Plugin** to activate the plugin 34 | 35 | After installing, go to **Settings | Taxonomy Filter** and select the taxonomies you want to filter for each custom post type. 36 | 37 | Then go to the all posts screen to see the filter above the table. 38 | 39 | == Frequently Asked Questions == 40 | 41 | == Screenshots == 42 | 1. Settings 43 | 2. Filters in action 44 | 45 | == Changelog == 46 | 47 | = 1.0.5 = 48 | - Fix text domain 49 | 50 | = 1.0.4 = 51 | - Fix deprecated notice in PHP 8.1 52 | 53 | = 1.0.3 = 54 | - Update compatibility with the latest version of WordPress 55 | 56 | = 1.0.2 = 57 | - Update compatibility tags 58 | 59 | = 1.0.1 = 60 | - Update compatibility with the latest version of WordPress 61 | 62 | = 1.0 = 63 | - First version 64 | 65 | == Upgrade Notice == 66 | --------------------------------------------------------------------------------