Add screen options to custom admin pages

You don’t need to invent a new screen option row. Just use proper metaboxes.

Currently, you are drawing pseudo-metaboxes:

<!-- Post status start-->
        <div class = "postbox">
            <div class = "handlediv"> <br> </div>
            <h3 class = "hndle"><span><?php _e("By Post Status", 'bulk-delete'); ?></span></h3>
        <div class = "inside">
        <h4><?php _e("Select the posts which you want to delete", 'bulk-delete'); ?></h4>

You should do this:

<div id="post-body-content">
    <!-- #post-body-content -->
</div>

<div id="postbox-container-1" class="postbox-container">
    <?php do_meta_boxes('','side',$object); ?>
</div>

<div id="postbox-container-2" class="postbox-container">
    <?php do_meta_boxes('','normal',$object); ?>
    <?php do_meta_boxes('','advanced',$object); ?>
</div>

Then register your own metaboxes with add_meta_box().

Read Meta Boxes on Custom Pages from Stephen Harris for all the details (demo on GitHub).
The main point is: You will get the screen options for these boxes for free.

And when WordPress changes the inner markup for metaboxes one day, your code will probably still work, because you have used the API.

Leave a Comment