Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#25070 new enhancement

Add filter to use do_accordion_sections for post metaboxes

Reported by: mzaweb's profile MZAWeb Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Editor Keywords: has-patch dev-feedback
Focuses: administration Cc:


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)

25070.diff (4.2 KB) - added by MZAWeb 11 years ago.
25070.2.diff (1.6 KB) - added by MZAWeb 11 years ago.

Download all attachments as: .zip

Change History (11)

11 years ago

#1 @MZAWeb
11 years ago

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;

#2 @DrewAPicture
11 years ago

  • Cc xoodrew@… added

#3 @MikeHansenMe
11 years ago

  • Keywords has-patch added

11 years ago

#4 @MZAWeb
11 years ago

Added same patch but without whitespace in the diff

#5 @DrewAPicture
11 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 @MZAWeb
11 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.

#7 @helen
11 years ago

I am super wary of custom callbacks here due to UI consistency and usability concerns. Just for the record.

#8 @emzo
10 years ago

  • Cc wordpress@… added

#9 @chriscct7
9 years ago

  • Component changed from Administration to Editor
  • Focuses administration added
  • Keywords dev-feedback added; 2nd-opinion removed
Note: See TracTickets for help on using tickets.