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/types.php

    r52389 r53126  
    162162        // Should fall back to 'public'.
    163163        $this->assertSame( $public, $args->show_in_admin_bar );
     164    }
     165
     166    /**
     167     * @ticket 53212
     168     * @covers ::register_post_type
     169     */
     170    public function test_fires_registered_post_type_actions() {
     171        $post_type = 'cpt';
     172        $action    = new MockAction();
     173
     174        add_action( 'registered_post_type', array( $action, 'action' ) );
     175        add_action( "registered_post_type_{$post_type}", array( $action, 'action' ) );
     176
     177        register_post_type( $post_type );
     178        register_post_type( $this->post_type );
     179
     180        $this->assertSame( 3, $action->get_call_count() );
    164181    }
    165182
Note: See TracChangeset for help on using the changeset viewer.