-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Update add_meta_boxes hook documentation to more accurately reflect the proper types
#10527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0134e9
Update hook document to more accurately reflect the proper types
opr 223bed7
Update hook documentation for add_meta_boxes_{}
opr eb4c11d
Update spacing
opr 068c9b4
Fix spacing
opr 29e2289
Update hook variable names to be more generic
opr ee6dc0b
Update hook docs for add_meta_boxes
opr ca5aad9
Update hook docs for `do_meta_boxes` too
opr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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', | ||
| * custom post types, 'comment', or 'link'. | ||
| * @param WP_Post|WP_Comment|object $post The post, comment, or link object. Type varies depending on | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, what about |
||
| * `$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 ); | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
$object_type?There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example:
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.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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_boxesin ca5aad9