Make WordPress Core

Opened 4 years ago

Closed 3 months ago

#55445 closed defect (bug) (wontfix)

Should WP_Post_Type preserve Array of capability_type?

Reported by: howdy_mcgee's profile Howdy_McGee Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

If I register a post type with capability_type as an array capbility_type => array( 'singular', 'plural' ). The WP_Post_Type object only holds onto the singular capability_type. Should the object preserve the array since it has singular and plural?

Change History (1)

#1 @SirLouen
3 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

https://developer.wordpress.org/reference/functions/get_post_type_capabilities/

By default WordPress uses singular, but if it has to use the plural for some specific capability that requires such, it will take the singular version with the "s" by the end.

Adding the plural explicitely is just to avoid this "s"-suffix behaviour, not to reference it at your convenience. Everything is preset and it will use the singular version when singular is hardcoded and the plural where plural is hardcoded.

Check this code snippet as a good example

As you can see, some capabilities are being referenced in the singular_base and others in the plural_base. This is what capability_type array is meant for.

Note: See TracTickets for help on using tickets.