Opened 12 years ago
Last modified 7 years ago
#25070 new enhancement
Add filter to use do_accordion_sections for post metaboxes
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.6 |
| Component: | Editor | Keywords: | has-patch dev-feedback |
| Focuses: | administration | Cc: |
Description
It'd be really cool to be able to use the new do_accordion_sections to render post metaboxes. Adding a filter to allow devs to do that, will also make easier to render custom styles (tabs or whatever).
Attached patch is a really quick proof of concept.
Attachments (2)
Change History (11)
#5
@
12 years ago
+1 for the idea, -1 for the approach in 25070.2.diff
I think we first need to make a decision about whether to DRY up the repeated code between do_meta_boxes() and do_accordion_sections(), then we can look at adding a filter or a flag or something to make this possible.
In 44:ticket:23450 and 23450.14.diff:ticket:23450 I suggested an approach to combining the two functions, though it was definitely too late in the cycle to consider a refactor as @nacin pointed out a few comments later.
Related: #23450
#6
@
12 years ago
I agree, the patch is just a proof of concept to quickly see how the accordion metaboxes look and feel like.
I still like the idea of allowing for custom style callbacks, though.
Sample usage:
add_filter( 'meta_boxes_style', 'set_custom_meta_box_style', 10, 4 ); add_filter( 'render_meta_boxes_my_style', 'render_custom_meta_box_my_style', 10, 4 ); function set_custom_meta_box_style( $style, $screen, $context, $object ) { if ( $context == 'normal' ) $style = 'accordion'; if ( $context == 'side' ) $style = 'my_style'; return $style; } function render_custom_meta_box_my_style( $i, $screen, $context, $object ) { // Do something fancy here. global $wp_meta_boxes; if ( empty( $screen ) ) $screen = get_current_screen(); elseif ( is_string( $screen ) ) $screen = convert_to_screen( $screen ); var_dump( $wp_meta_boxes[$screen->id][$context] ); return $i; }