Skip to content

Bundled Themes: Document the parameters of five template functions - #12792

Open
jigneshbhavani wants to merge 1 commit into
WordPress:trunkfrom
jigneshbhavani:fix/64896-bundled-themes-param-docs
Open

Bundled Themes: Document the parameters of five template functions#12792
jigneshbhavani wants to merge 1 commit into
WordPress:trunkfrom
jigneshbhavani:fix/64896-bundled-themes-param-docs

Conversation

@jigneshbhavani

Copy link
Copy Markdown

Five functions in Twenty Nineteen and Twenty Twelve take arguments but have no @param tag 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 as bool|string, because comments.php calls it three times, with 'desc', 'asc', and true. The body reads if ( true === $order || strtolower( $order ) === strtolower( get_option( 'comment_order', 'asc' ) ) ), so true forces 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 in twentynineteen_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 to get_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 a wp_page_menu_args filter callback and returns the array, so it gains a @return as well.

What is deliberately not changed

No @since tags 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. phpcs passes 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, ran phpcs, 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.

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.
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props bejignesh.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant