Make WordPress Core

Opened 6 years ago

Last modified 8 weeks ago

#25070 reopened enhancement

Add filter to use do_accordion_sections for post metaboxes

Reported by: MZAWeb Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.6
Component: Editor Keywords: has-patch, dev-feedback, bulk-reopened
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 6 years ago.
25070.2.diff (1.6 KB) - added by MZAWeb 6 years ago.

Download all attachments as: .zip

Change History (14)

6 years ago

#1 @MZAWeb
6 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
6 years ago

  • Cc xoodrew@… added

#3 @MikeHansenMe
6 years ago

  • Keywords has-patch added

6 years ago

#4 @MZAWeb
6 years ago

Added same patch but without whitespace in the diff

#5 @DrewAPicture
6 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
6 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
6 years ago

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

#8 @emzo
5 years ago

  • Cc wordpress@… added

#9 @chriscct7
4 years ago

  • Component changed from Administration to Editor
  • Focuses administration added
  • Keywords dev-feedback added; 2nd-opinion removed

#10 @iseulde
4 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

This ticket has not seen any activity in over two years, so I'm closing it as "wontfix". It may not be relevant anymore, or there just may not be enough interest in it to keep it around. If you think this ticket does deserve some attention again, feel free to reopen with updated steps to reproduce with WordPress 5.0.

#11 @ocean90
4 months ago

  • Keywords changed from has-patch dev-feedback to has-patch, dev-feedback
  • Milestone Awaiting Review deleted

#12 @JeffPaul
8 weeks ago

  • Keywords bulk-reopened added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

A decision was made to reopen tickets that were closed in the bulk edit that this ticket was affected by. This ticket is being placed back into the Awaiting Review milestone so it can be individually evaluated and verified to determine if it is still relevant/valid or reproducible.

Note: See TracTickets for help on using tickets.