WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 7 weeks ago

Last modified 7 weeks ago

#25070 closed enhancement (wontfix)

Add filter to use do_accordion_sections for post metaboxes

Reported by: MZAWeb 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)

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

Download all attachments as: .zip

Change History (13)

@MZAWeb
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

@MZAWeb
5 years ago

#4 @MZAWeb
5 years ago

Added same patch but without whitespace in the diff

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

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

#10 @iseulde
7 weeks 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
7 weeks ago

  • Keywords changed from has-patch dev-feedback to has-patch, dev-feedback
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.