Make WordPress Core


Ignore:
Timestamp:
04/11/2022 05:09:53 AM (3 years ago)
Author:
peterwilsoncc
Message:

Posts, Post Types/Taxonomies: Add object type specific registration filters.

Add post type and taxonomy specific registration argument hooks.

Introduces the filters register_{$post_type}_post_type_args and register_{$taxonomy}_taxonomy_args. Introduces the actions registered_post_type_{$post_type} and registered_taxonomy_{$taxonomy}.

Props pbiron, dlh, davidbaumwald, hellofromTonya, milana_cap.
Fixes #53212.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/wpTaxonomy.php

    r52389 r53126  
    100100
    101101    }
     102
     103    public function test_applies_registration_args_filters() {
     104        $taxonomy = 'taxonomy5';
     105        $action   = new MockAction();
     106
     107        add_filter( 'register_taxonomy_args', array( $action, 'filter' ) );
     108        add_filter( "register_{$taxonomy}_taxonomy_args", array( $action, 'filter' ) );
     109
     110        new WP_Taxonomy( $taxonomy, 'post' );
     111        new WP_Taxonomy( 'random', 'post' );
     112
     113        $this->assertSame( 3, $action->get_call_count() );
     114    }
    102115}
Note: See TracChangeset for help on using the changeset viewer.