WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 5 months ago

#40413 reviewing enhancement

Handle `register_post_type` support's array

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

Description

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 13 months ago.
Patch 40413-1
ticket-40413.2.patch (2.0 KB) - added by seuser 8 months ago.

Download all attachments as: .zip

Change History (7)

@MaximeCulea
13 months ago

Patch 40413-1

#1 @MaximeCulea
13 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
13 months ago

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

#3 @seuser
8 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.

#4 @MaximeCulea
5 months ago

Hi there ! @swissspidy ready to merge ? Thx

#5 @swissspidy
5 months ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to swissspidy
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.