Bundled Themes: Document the parameters of five template functions - #12792
Bundled Themes: Document the parameters of five template functions#12792jigneshbhavani wants to merge 1 commit into
Conversation
Five functions in Twenty Nineteen and Twenty Twelve accept arguments but carry no `@param` tag at all. * Twenty Nineteen: `twentynineteen_get_user_avatar_markup()`, `twentynineteen_discussion_avatars_list()`, and `twentynineteen_comment_form()` had a description and nothing else. The first also returns markup, so it gains a `@return`. * Twenty Twelve: `twentytwelve_page_menu_args()` and `twentytwelve_content_nav()`, in a file that otherwise documents its parameters throughout. The types come from the call sites. `twentynineteen_comment_form()` is called with `'asc'`, `'desc'`, and `true`, so it is documented as `bool|string`. The authors passed to `twentynineteen_discussion_avatars_list()` are built in `twentynineteen_get_discussion_data()` as a user ID, or the author email where there is no account. No `@since` tags are added. The Twenty Nineteen file does not use them on functions, and the two Twenty Twelve functions already have them. No functional change. See #64896.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Five functions in Twenty Nineteen and Twenty Twelve take arguments but have no
@paramtag at all, just a one line description.Twenty Nineteen (
inc/template-tags.php)twentynineteen_get_user_avatar_markup( $id_or_email = null )twentynineteen_discussion_avatars_list( $comment_authors )twentynineteen_comment_form( $order )Twenty Twelve (
functions.php)twentytwelve_page_menu_args( $args )twentytwelve_content_nav( $html_id )The Twenty Twelve file documents parameters throughout, so those two stand out as gaps rather than a house style.
Notes on the types
They come from the call sites, not from guesswork.
twentynineteen_comment_form()is documented asbool|string, becausecomments.phpcalls it three times, with'desc','asc', andtrue. The body readsif ( true === $order || strtolower( $order ) === strtolower( get_option( 'comment_order', 'asc' ) ) ), sotrueforces display while a string only displays when it matches the option. The description says that rather than just listing the types.twentynineteen_discussion_avatars_list()receives$discussion->authors, built intwentynineteen_get_discussion_data()as( (int) $comment->user_id > 0 ) ? (int) $comment->user_id : $comment->comment_author_email, so entries are a user ID or an email address where there is no account.twentynineteen_get_user_avatar_markup()passes its argument straight toget_avatar(), so it takes that function's wording for the accepted types. It also returns markup, so it gains a@return.twentytwelve_page_menu_args()is awp_page_menu_argsfilter callback and returns the array, so it gains a@returnas well.What is deliberately not changed
No
@sincetags are added. The Twenty Nineteen file does not use them on functions, and adding them would mean guessing at versions. The two Twenty Twelve functions already have theirs.No functional change.
phpcspasses on both files.Trac ticket: https://core.trac.wordpress.org/ticket/64896
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Scanning
src/for functions whose docblocks omit their parameters, which is how these were found, and drafting this description. I read each call site to confirm the types, ranphpcs, and I take responsibility for the change.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.