I can’t get the toggle state and open/close status of meta_boxes on my plugin admin page to be stored. The ajax response is always 0
I’m using meta boxes to hold sections of menu for a plugin.
wp_enqueue_script( 'common' );
wp_enqueue_script( 'wp-lists' );
wp_enqueue_script( 'postbox' );
are called on an init add_action hook
add_meta_boxes are called with admin_menu add_action hook
Then the admin page for my plugin is rendered thus…
<div class="wrap" id="church-admin">
<div id="icon-index" class="icon32"><br/></div><h2>Church Admin Plugin</h2>
<div id="poststuff">
<!-- #post-body .metabox-holder goes here -->
<div id="post-body" class="metabox-holder columns-2">
<!-- meta box containers here -->
<form style="display:none" method="get" action="">
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
</form>
<?php do_meta_boxes('church-admin','advanced',null);?>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($){$(".if-js-closed").removeClass("if-js-closed").addClass("closed");
postboxes.add_postbox_toggles( pagenow );
});
</script>
Why are opn/close toggles and order changes not saved?
To get the save to work the
postboxes.add_postbox_toggles( pagenow );
needs to be replaced withIn my case
postboxes.add_postbox_toggles( 'church-admin' );
I’ve blogged a how to using meta boxes on plugin admin pages