#59839 closed enhancement (fixed)
Twenty Twenty-Four: register_block_pattern_category()'s slug/$category_name should be prefixed
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | good-first-bug has-patch commit |
Focuses: | Cc: |
Description
https://themes.trac.wordpress.org/browser/twentytwentyfour/1.0/functions.php#L197
Plugins can change the proprieties (label/description) even by mistake.
Attachments (1)
Change History (16)
This ticket was mentioned in Slack in #core by jorbin. View the logs.
15 months ago
#2
@
13 months ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to 6.5
#3
@
13 months ago
- Keywords has-patch added; needs-patch removed
I have added patch as per suggested in above comment
#5
@
13 months ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://core.trac.wordpress.org/attachment/ticket/59839/59839.patch
Environment
OS: Windows
PHP: 8.1.9
WordPress: 6.4.2
Browser: Chrome
Theme: Twenty Twenty-Four
Plugins: None activated
Actual Results:
✅ After patch: twentytwentyfour_page pattern category is prefix now.(not changeable / override via plugin / custom code )
Backend: https://prnt.sc/4IXCfFOyOOwu
Frontend:
#6
@
12 months ago
- Keywords commit added; 2nd-opinion needs-testing removed
I'm trying to think of if there are any side effects, but no, I can't think of any. This works well in my testing, thank you.
-When creating a new custom pattern, the Pages category is available, working correctly.
#7
@
12 months ago
The categories in Twenty Twenty-Two are also not prefixed (see twentytwentytwo_register_block_patterns()
). Should the same change be made there?
All other default themes just use their theme name as the category name.
#10
@
12 months ago
Good find.
I have now had a look at the categories in Twenty Twenty-two:
I found that featured, footer, header, and query are also registered by WordPress:
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/block-patterns.php#L61
If the slug is updated, these categories show as duplicates on supported WordPress versions.
We also can't remove them because then the categories would be missing on older WordPress versions.
But we can update the final slug, pages
.
This ticket was mentioned in PR #6066 on WordPress/wordpress-develop by @poena.
12 months ago
#11
Trac ticket:
https://core.trac.wordpress.org/ticket/59839
Follow up to https://core.trac.wordpress.org/ticket/59839#comment:7
@shailu25 commented on PR #6066:
12 months ago
#12
Hi @carolinan
Thanks for Patch.
You have added font file(OpenSans-Regular.ttf). it should be remove from the patch
There 3 more files which have Pages category it also should be changed
- /inc/patterns/page-about-large-image-and-buttons.php
- /inc/patterns/page-about-links-dark.php
- /inc/patterns/page-about-links.php
#14
@
12 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 57569:
@SergeyBiryukov commented on PR #6066:
12 months ago
#15
Thanks for the PR! Merged in r57569.
To clarify, register_block_attern_category() accepts the parameter $category_name, which in Twenty Twenty-Four is 'page':
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:
The theme patterns with
Would need to be updated to use the new prefixed parameter: