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/post/wpPostType.php

    r51404 r53126  
    217217        $this->assertSameSets( array(), $taxonomies_after );
    218218    }
     219
     220    public function test_applies_registration_args_filters() {
     221        $post_type = 'cpt';
     222        $action    = new MockAction();
     223
     224        add_filter( 'register_post_type_args', array( $action, 'filter' ) );
     225        add_filter( "register_{$post_type}_post_type_args", array( $action, 'filter' ) );
     226
     227        new WP_Post_Type( $post_type );
     228        new WP_Post_Type( 'random' );
     229
     230        $this->assertSame( 3, $action->get_call_count() );
     231    }
    219232}
Note: See TracChangeset for help on using the changeset viewer.