Build: Document the hooks generated by the wp-build page templates#78826
Conversation
In the page templates, add a docblock for the per-page init action
({{PAGE_SLUG}}_init / {{PAGE_SLUG}}-wp-admin_init) so generated pages document
the hook. No @SInCE is given because the shared template serves pages
introduced in different versions.
Replace the duplicated copies of core hook docblocks (admin_head,
admin_head-{$hook_suffix}, admin_footer, admin_footer-{$hook_suffix}) with the
standard "This action is documented in ..." reference comments, matching how
WordPress core references hooks documented elsewhere.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in cfbeca0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26664863194
|
|
Let's backport this PR to 7.0.1 as well, so that #75985 can be correctly backported to 7.0.1. |
|
It looks like this never made its way into the |
I believe that unlike Beta releases, automatic cherry-picking based on labels is not performed for minor releases. I think manual cherry-picking is necessary for minor releases. Example: #74806 |
What?
Follow up to #73120 and #73137.
The
@wordpress/buildpage templates generate PHP files (output underwp-includes/build/pages/…) that invoke action hooks. This PR brings those hooks in line with the WordPress PHP documentation standards:{page_slug}_initinpage.php.template,{page_slug}-wp-admin_initinpage-wp-admin.php.template), which previously had only a//line comment.admin_head,admin_head-{$hook_suffix},admin_footer,admin_footer-{$hook_suffix}) inpage.php.templatewith the standard/** This action is documented in … */reference comments.No behavior changes — documentation only.
Why?
Every action and filter should be documented, either with an inline DocBlock or, when the hook is documented elsewhere, with a
This action/filter is documented in <file>reference comment. The page templates currently fall short in two ways:{page_slug}_init/{page_slug}-wp-admin_initcarry only a// Fire init action…line comment, so every generated page ships an undocumented hook.admin_head,admin_footer, and their-{$hook_suffix}variants verbatim. These hooks are defined and documented inwp-admin/admin-header.phpandwp-admin/admin-footer.php; core itself never duplicates a hook's DocBlock and instead uses the "documented in" reference. Duplicating risks the copies drifting from the canonical documentation and misrepresents where the hooks are defined.(For context, a PHPStan rule being added on the WordPress core side flags exactly these two patterns, which is how they surfaced.)
How?
do_action()in both page templates. No@sinceis included: a single shared template generates pages introduced in different versions, so no single version would be correct for the substituted hook name.page.php.templatewith/** This action is documented in wp-admin/admin-header.php */and/** This action is documented in wp-admin/admin-footer.php */as appropriate.{page_slug}_boot_dependenciesfilter's DocBlock untouched — it is a genuinely new, page-specific filter (not a re-fire of a core hook), so its inline DocBlock is the canonical documentation and is correct as-is.Testing Instructions
This is a documentation-only change to the build templates; there is no runtime behavior change.
npm run build.build/pages/font-library/page.php:do_action( 'font-library_init' )is now preceded by a/** … */DocBlock.admin_head,admin_head-{$hook_suffix},admin_footer, andadmin_footer-{$hook_suffix}calls are now preceded by/** This action is documented in … */reference comments instead of copied DocBlocks.build/pages/.../page-wp-admin.php, and confirm the…-wp-admin_initaction now has a DocBlock.Testing Instructions for Keyboard
N/A — no UI changes.
Screenshots or screencast
N/A — documentation-only change to generated PHP.
Use of AI Tools
This pull request was authored with the assistance of Claude Code (Claude Opus). All changes were reviewed by the contributor, who takes responsibility for them.