Opened 11 years ago
Closed 11 years ago
#25433 closed defect (bug) (wontfix)
do_action( 'do_meta_boxes' ) is a redundant hook
Reported by: | ericlewis | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | dev-feedback |
Focuses: | Cc: |
Description
As I understand, the do_meta_boxes hook "should be" fired when the meta boxes should be displayed. @scribu mentioned as much on wp-hackers a while ago. It was moved out of the beginning of the do_meta_boxes() function into separate edit-form-*.php files before the admin header is called in r9620 for undocumented reasons.
This hook is no more helpful than add_meta_boxes and fires right after it. I would suggest that we deprecate this hook, and suggest developers use the add_meta_boxes hook instead.
Change History (3)
#2
@
11 years ago
I'm actually not sure how redundant it is. add_meta_boxes is for *adding* meta boxes. do_meta_boxes is designed to let people manipulate the registered meta boxes once they are registered but before they are rendered.
Normally, we'd just suggest a later priority on the hook, and not introduce a second hook. But, these particular hooks are well established. And we do occasionally implement hooks to fire immediately after (or before, depending) a particularly popular/common hook to make it less of a juggle with priorities. For example, wp_loaded after init, admin_enqueue_scripts before admin_print_scripts.
It might not be obvious at first, but it's pretty easy to explain why things moved in [9620]. Basically, that commit was the start of "Screen Options", which is rendered as part of the admin header. (It wasn't originally there as you can tell; that commit moved it there, but its introduction was also in the same development cycle, which was 2.7.) So, it became necessary for do_meta_boxes to be called earlier, to make sure that any manipulations were properly reflected in screen options.
As #13017 explains, maybe we shouldn't have set this up this way. But we don't really have many "deprecated" hooks, and certainly not one that's this popular.
Related: #13017