Opened 11 years ago
Closed 11 years ago
#26869 closed task (blessed) (fixed)
Hook Docs clean up
Reported by: | DrewAPicture | Owned by: | |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | docs | Cc: |
Description (last modified by )
We'll use this ticket as a clearing house fixes to the list of files found on make/docs: http://make.wordpress.org/docs/closed-hook-tickets-review/
Changes may include cleaning up any discrepancies in terms of spacing, code that was unnecessarily moved (such as in the case of filterable arrays, in-line @
tags, etc.
Attachments (18)
Change History (60)
This ticket was mentioned in IRC in #wordpress-dev by jeremyfelt. View the logs.
11 years ago
This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.
11 years ago
#13
@
11 years ago
Small hook docs tweaks for wp-admin/includes/misc.php - order of tags, spacing between tags, and clearer English.
#14
@
11 years ago
Added load-back-compat.diff which clarifies a comment on back-compat hooks of the load-* variety.
Notes and todo items from @kpdesign's audit(s):
Missing or incomplete docs for the following hooks:
wp_header_image_attachment_metadata
wp_create_file_in_uploads
(duplicate)- Long description for
do_mu_upgrade filter
- "it is automatically fired" - what is fired? get_attached_media
Suggested changes by file:
wp-admin/includes/menu.php:
- Fix erroneous phpdoc tag for 3 hooks:
_network_admin_menu
,_user_admin_menu
,_admin_menu
.
wp-admin/includes/plugin-install.php:
- Add missing docs variable for
plugins_api
hook.
wp-admin/network/admin.php:
- Fix incorrect docs variable for
redirect_network_admin_request
hook (copy/pasta error).
wp-admin/options-discussion.php:
- Change docs variable for
thread_comments_depth_max
hook to indicate what that number represents$max_depth
.
wp-admin/options-writing.php:
- Fix short description and add missing docs variable for
enable_update_services_configuration
hook.
wp-admin/options.php:
- Fix short description and add missing docs variable for
enable_post_by_email_configuration
hook.
wp-admin/user/admin.php:
- Fix short description, remove long description for
redirect_user_admin_request
hook.
wp-includes/class-wp-embed.php:
- Add missing
@since
value forembed_oembed_discover
hook.
wp-includes/class-wp-xmlrpc-server.php:
wp-includes/comment-template.php:
get_comment_excerpt
missing docspings_open
missing docsthe_permalink
(twice as duplicates)- Add missing
@since
values forcomments_open
andget_comments_link
hooks.
wp-includes/l10n.php:
- Fix duplicate hook lines for
locale
andplugin_locale
hooks. - Fix typo in short description for
override_unload_textdomain
hook. - Add missing docs variables for
override_load_textdomain
andoverride_unload_textdomain
hooks, fix alignment due to change.
#23
follow-up:
↓ 24
@
11 years ago
@nacin:
- admin_post_actions.diff is a proposed attempt to handle the dynamic hook currently designated as
$action
- do_feed.diff is a proposed attempt to handle (one of several) dynamic hook(s) currently designated as
$hook
#24
in reply to:
↑ 23
@
11 years ago
Replying to DrewAPicture:
- admin_post_actions.diff is a proposed attempt to handle the dynamic hook currently designated as
$action
You've changed behaviour there I think. The old code allowed hooks of:
action_post
(logged in, request action empty)action_post_nopriv
(not logged in, request action empty)action_post_{$action}
(logged in, request action populated)action_post_nopriv_{$action}
(not logged in, request action populated)
The new code appears to allow (re-ordered to match above):
admin_post_
(logged in, request action empty - different)action_post_nopriv_
(not logged in, request action empty - different)action_post_{$action}
(logged in, request action populated)action_post_nopriv_{$action}
(not logged in, request action populated)
Now I've written it out, it looks like it's just the underscore before an empty ${action} that needs to be handled better.
#25
follow-up:
↓ 26
@
11 years ago
For the admin_post one, I suggest something more like this:
if ( !empty($_REQUEST['action']) ) $request_action = '_' . $_REQUEST['action'];
and then have both:
do_action( "admin_post_nopriv{$request_action}" );
do_action( "admin_post{$request_action}" );
In your if/else.
#26
in reply to:
↑ 25
@
11 years ago
Replying to Otto42:
For the admin_post one, I suggest something more like this:
if ( !empty($_REQUEST['action']) ) $request_action = '_' . $_REQUEST['action'];and then have both:
do_action( "admin_post_nopriv{$request_action}" );
do_action( "admin_post{$request_action}" );
In your if/else.
Yup, works for me. I was unsure about whether there would ever be a case of "admin_post_" (invalid or empty action), and whether that would actually constitute a separate, valid hook.
#27
@
11 years ago
screenid.diff and perpage.2.diff look good to me. Working on a new patch for the admin_post_ actions.
#29
@
11 years ago
- Summary changed from Hook Docs completed files fixes to Hook Docs clean up
For anyone interested, the reason we're converting several (possibly many) dynamic hook names to use interpolation instead of concatenation is due a need for consistency with the new code reference. Concatenated hook names are tougher to grok.
#31
@
11 years ago
In the [28349] message, should be $action
instead of $request_action
in the hook names. Oops.
#35
@
11 years ago
I'm not in favour of r28349 as it stands.
Looking at just one of them:
/** * Fires the requested handler action for logged-out users. * * The dynamic portion of the hook name, $action, refers to the handler action. * * @since 2.6.0 */ do_action( "admin_post_nopriv{$action}" );
Imagine that is taken out of context and shown on devhub. That now looks like I can provide a handler action of foobar
and I can hook into the admin_post_noprivfoobar
hook. There's no mention that $action
is given an underscore prefix in the hook doc, or perhaps worse, the hook name doesn't reflect that the (missing) underscore is static and always present.
I think here I'd rather see four explicit hooks that are clearly named and unambiguous, than two that are misnamed and don't appear to follow the naming consistency of other dynamic hooks.
wp-comments-post.php [25249]