Daniel Dvorkin

My take on WordPress and related geekery

7093898-md

do_accordion_sections

WordPress 3.6 comes with a hidden goody. Well, it’s not really hidden, but I just spotted it a few days ago. It’s called do_accordion_sections and it’s used to render the sections in the new menu manager:

menu-manager

But the cool thing about it is that it’s basically a replacement for do_meta_boxes. So, with just a few lines of code you can make it work, for instance, in your Custom Post Type edit screen. Why? Just because!

Simple and hacky code to make this change for Pages.

add_action( 'edit_form_after_editor', 'testing_accordion_section' );

function testing_accordion_section() {

	$screen = get_current_screen();
	
	if ( $screen->id != 'page' )
		return;

	do_accordion_sections( $screen, 'normal', get_post() );

	global $wp_meta_boxes;
	$wp_meta_boxes[$screen->id]['normal'] = array();
}

And the ‘normal’ metaboxes in the Page edit screen will render like:

pages
pages2

I created a Trac ticket and submitted a patch to allow you select this metaboxes style just using a filter, or implement custom metabox styles. (tabs, etc)

Previous

mu-plugins, maybe.

Leave a Reply

Powered by WordPress & Theme by Anders Norén