bueltge / wordpress-admin-style

This plugin reference elements from wp-admin in an overview with the necessary markup and CSS classes to help you to develop WordPress compliant.
http://wpengineer.com/2226/new-plugin-to-style-your-plugin-on-wordpress-admin-with-default-styles/
GNU General Public License v2.0
960 stars 124 forks source link

How to make collapsible meta boxes #53

Closed ckristhoff closed 6 years ago

ckristhoff commented 6 years ago

Hi First, awesome project! I'm developing my first plugin for Wordpress 4.9 and this project is really useful. I'm trying to use meta boxes for settings sections but it does not collapse.

x9t9 commented 6 years ago

I am not 100% sure I understand your issue, but if I do than you need to add the corresponding JS to your settings section ( postbox.js - you will find it in the admin/js folder or just use wp_enqueue_script('postbox'); ) . Other option is write your own to make things short .

As far as I remember , it is indeed not included in the plugin.

bueltge commented 6 years ago

I have a small javascript inside an other plugin to close/open meta boxes. maybe this helps you. https://github.com/bueltge/adminimize/blob/e27044bf79cf48fd20ec966a011224d8a50b811f/js/adminimize.js#L25-L32

I add, remove only the default css classes from the WP Core to hide, show the areas.

ckristhoff commented 6 years ago

Just as @x9t9 said: wp_enqueue_script('postbox'); but, you must add next script: jQuery(document).ready(function(){ postboxes.add_postbox_toggles(pagenow); }); voila!

bueltge commented 6 years ago

@ckristhoff I close this issue because in my opinion the question is clarified. If I'm wrong, please feel free to reopen it.