Opened 11 years ago
Last modified 6 years ago
#31559 new enhancement
Meta boxes should have before/after hooks
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | has-patch 2nd-opinion |
| Focuses: | administration | Cc: |
Description
Currently there is no way to hook into an existing metabox. If I wanted to modify the featured image metabox (add a checkbox or something), I'd have to unregister the metabox, and re-register w/ my own callback. This is not good for compatibility w/ other plugins, etc.
I propose before_callback and after_callback hooks for metaboxes.
Basically, we'd replace this:
echo '<div class="inside">' . "\n"; call_user_func($box['callback'], $object, $box); echo "</div>\n";
with:
echo '<div class="inside">' . "\n";
do_action( 'before_metabox_callback', $object, $box );
do_action( "before_{$box['id']}_metabox_callback", $object, $box );
call_user_func($box['callback'], $object, $box);
do_action( 'after_metabox_callback', $object, $box );
do_action( "after_{$box['id']}_metabox_callback", $object, $box );
echo "</div>\n";
Attachments (1)
Change History (6)
#4
@
10 years ago
I'd like to see more extensibility on these features too. Adding extra meta boxes on the same subject seems unorganized and adds unneeded clutter.
A simple filter or a do_action() would be nice.
e.g.:
// Line 763 meta-boxes.php:
<p><strong><?php _e('Order') ?></strong></p>
<p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
<?php do_action( 'after_page_attributes_meta_box' ); ?>
<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) { ?>
<p><?php _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
<?php
}
A nice scenario would be to add the wpautop filter option to that section through a plugin.
Note: See
TracTickets for help on using
tickets.
I'd rather see this on a case-by-case basis - maintaining something like this into the future seems painful at best.