Make WordPress Core

Opened 7 months ago

Last modified 2 months ago

#40413 new enhancement

Handle `register_post_type` support's array

Reported by: MaximeCulea Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.9
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:


When registering a post_type's support with the add_post_type_support() function, it's possible to pass "extra" args to the support, because of the func_num_args which will check if there is a third arg.

While when using register_post_type(), you can't pass any extra args to a support, because it will be stripped by how WP_Post_Type->add_supports works.

Attachments (2)

ticket-40413.patch (1.1 KB) - added by MaximeCulea 7 months ago.
Patch 40413-1
ticket-40413.2.patch (2.0 KB) - added by seuser 2 months ago.

Download all attachments as: .zip

Change History (5)

7 months ago

Patch 40413-1

#1 @MaximeCulea
7 months ago

  • Keywords has-patch added

So, as I think this behaviour of giving to a support some more extra features is cool, I submit a patch in this direction.
Now from register_post_type you could register a support with extra args as following :
<?php register_post_type( 'post_type', [ 'supports' => [ 'support' => [ extra_1, extra_2 ] ] ] );

#2 @swissspidy
7 months ago

  • Keywords needs-unit-tests added
  • Type changed from defect (bug) to enhancement
  • Version changed from trunk to 2.9

#3 @seuser
2 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

First shot at something in the Trac so go easy on me :) I've added a test which fails without your patch and now passes with it.

Note: See TracTickets for help on using tickets.