Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/wp-admin/includes/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1677,25 +1677,31 @@ function register_and_do_post_meta_boxes( $post ) {
*
* @since 3.0.0
*
* @param string $post_type Post type.
* @param WP_Post $post Post object.
* @param string $post_type Post type of the current screen. Can be 'post', 'page',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about $object_type?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like the idea. Would you expect the variable passed to the hook to be renamed too, or just renamed in the documentation?

Copy link
Copy Markdown
Author

@opr opr Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example:

	/**
	 * Fires after all built-in meta boxes have been added.
	 *
	 * @since 3.0.0
	 *
	 * @param string                    $object_type The type of the current object that meta boxes were added to.
	 *                                               Can be 'post', 'page', custom post types, 'comment', or 'link'.
	 * @param WP_Post|WP_Comment|object $object      The post, comment, or link object. Type varies depending on
	 *                                               `$post_type`.
	 */
	do_action( 'add_meta_boxes', $post_type, $post );

renaming the actual variable passed would require it throughout the file, or creating a new variable just before firing the hook.

I don't mind assigning to a new variable, but not keen on renaming through the whole file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just renaming the variable in the hook docs. There shouldn't be a need to change any PHP variable names or add new variables.

Copy link
Copy Markdown
Author

@opr opr Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I also applied similar changes to do_meta_boxes in ca5aad9

* custom post types, 'comment', or 'link'.
* @param WP_Post|WP_Comment|object $post The post, comment, or link object. Type varies depending on
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, what about $object?

* `$post_type`.
*/
do_action( 'add_meta_boxes', $post_type, $post );

/**
* Fires after all built-in meta boxes have been added, contextually for the given post type.
*
* The dynamic portion of the hook name, `$post_type`, refers to the post type of the post.
* The dynamic portion of the hook name, `$post_type`, refers to the post type of the post,
* or the object type (comment, link).
*
* Possible hook names include:
*
* - `add_meta_boxes_post`
* - `add_meta_boxes_page`
* - `add_meta_boxes_attachment`
* - `add_meta_boxes_comment`
* - `add_meta_boxes_link`
*
* @since 3.0.0
*
* @param WP_Post $post Post object.
* @param WP_Post|WP_Comment|object $post The post, comment, or link object. Type varies depending on
* the hook name.
*/
do_action( "add_meta_boxes_{$post_type}", $post );

Expand Down
Loading