I have several metaboxes in the edit screen.
I would also create another metabox where the user can click on a checkbox then it hides a set of metaboxes, similar to the Screen Options functionality, only when the checkbox is clicked, it hides/toggles a group of metaboxes.
Does anybody know how to approach this? If not, what’s the code used by the Screen Options menu that dictates on click,hide metabox. ?
Thanks.
The toggling boxes part is easy enough, that i can manage, but saving the status of the boxes is more tricky. JS unfortunately is not one of my strengths, and i can’t get the postboxes to save their state. That said, i can show you how to toggle groups of boxes, and adjust the checkboxes accordingly, i’ll post this in the hope that someone else can fill in the missing links to get the post box states to update(else when you refresh or revisit the screen, groups of boxes you’ve toggled visibility for won’t have remembered their state).
HTML for the toggle links
The spans need not be spans, you can of course use inputs or whatever you like to hold a comma seperated list of the boxes to toggle(a list of their IDs).
jQuery/JS for toggling
The postbox code you see in there is commented out as it doesn’t work(had hoped it would), i’m simply not JS knowledgable enough to know what i’m missing on that front, but i’ve left it there so others in a position to help can see what i’ve tried.. 😉
Sorry i couldn’t give a complete answer, but i hope that helps all the same.. 🙂