Admin area ‘toggle’ w/ cookie

the wordpress admin already uses some kind of toggle on the menu and on metaboxes.. w/ “Click to Toggle” buttons that remember the open versus closed state. Does anybody know what code is responible for this? I’d like to implement it into sections of my custom metaboxs, and it doesn’t seem like I should need to add a script to the admin area (b/c it is already slow) when WP has this functionality by default.

3 Answers
3

Checkout the HTML for a WP meta-box :

<div id="my_div" class="postbox ">
    <div class="handlediv" title="Click to toggle."><br></div>
    <h3 class="hndle"><span>title</span></h3>
    <div class="inside">
        ...
    </div>
</div>

If you follow that structure (and CSS classes) in your custom meta-box, the toggle will work.

Leave a Comment