[wp-trac] [WordPress Trac] #59839: Twenty Twenty-Four: register_block_pattern_category()'s slug/$category_name should be prefixed

WordPress Trac noreply at wordpress.org
Tue Jan 23 09:40:41 UTC 2024


#59839: Twenty Twenty-Four: register_block_pattern_category()'s slug/$category_name
should be prefixed
----------------------------------------------------+---------------------
 Reporter:  acosmin                                 |       Owner:  (none)
     Type:  enhancement                             |      Status:  new
 Priority:  normal                                  |   Milestone:  6.5
Component:  Bundled Theme                           |     Version:
 Severity:  normal                                  |  Resolution:
 Keywords:  2nd-opinion needs-patch good-first-bug  |     Focuses:
----------------------------------------------------+---------------------
Changes (by poena):

 * keywords:  2nd-opinion => 2nd-opinion needs-patch good-first-bug
 * milestone:  Awaiting Review => 6.5


Comment:

 To clarify, register_block_attern_category() accepts the parameter
 $category_name, which in Twenty Twenty-Four is 'page':


 {{{
 register_block_pattern_category(
                         'page',
                         array(
                                 'label'       => _x( 'Pages', 'Block
 pattern category', 'twentytwentyfour' ),
                                 'description' => __( 'A collection of full
 page layouts.', 'twentytwentyfour' ),
         )
 );
 }}}

 If a plugin also registers the category name 'page' in an init hook that
 runs after the theme's, it can override the label and description
 unintentionally.

 With a prefix, extenders can still override it, but it would be
 intentional.
 Adding a prefix now will stop any existing overrides from working,
 intentional or not: either way, it is a minor problem since it would only
 affect a label and description.


 The proposed fix is to prefix parameter similarly to this:

 {{{
 register_block_pattern_category(
                         'twentytwentyfour_page',
                         array(
                                 'label'       => _x( 'Pages', 'Block
 pattern category', 'twentytwentyfour' ),
                                 'description' => __( 'A collection of full
 page layouts.', 'twentytwentyfour' ),
         )
 );
 }}}

 The theme patterns with
 {{{
  * Categories: page
 }}}
 Would need to be updated to use the new prefixed parameter:

 {{{
  * Categories: twentytwentyfour_page
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59839#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list