getSupportedTaxonomies() as $taxonomy ) { add_action( "{$taxonomy}_add_form_fields", [ $this, 'renderAdd' ] ); add_action( "{$taxonomy}_edit_form_fields", [ $this, 'renderEdit' ], 99 ); add_action( "create_{$taxonomy}", [ $this, 'saveTermFields' ], 10, 1 ); } add_filter( 'get_terms_args', function ( $args ) { if ( isset( $_GET[ self::UNDER_RESTRICTION_FILTER_KEY ] ) ) { $args['meta_query'] = array( array( 'key' => self::UNDER_RESTRICTION_META_KEY, 'value' => 'yes', 'compare' => '=' ) ); } return $args; } ); } /** * Save metadata to custom attributes terms * * @param int $term_id * @param $tt_id * @param $taxomomy */ public function saveTermFields( $term_id, $tt_id, $taxomomy ) { if ( in_array( $taxomomy, $this->getSupportedTaxonomies() ) ) { update_term_meta( $term_id, self::UNDER_RESTRICTION_META_KEY, isset( $_POST[ self::UNDER_RESTRICTION_META_KEY ] ) ? 'yes' : 'no' ); } } public function renderEdit( WP_Term $term ) { ?>