Typically, I had to do this to modify the DZone plug-in which had some ugly configuration to modify the post subpanel in the WordPress administration page.

Then, here the few things you need to do to create a beautiful meta-box within any WordPress post page :)

This code will works for any version of WordPress 2.x. Since wordpress 2.5, a new API has been defined to allow easily to add admin meta-box but if you want to create a plug-in compatible with older version of wordpress, here is the way…

First in your plug-in page add this piece of code. It will direct wordpress to listen any event of adding more stuff in the post page :

  1. add_action(‘dbx_post_advanced’, on_meta_boxes_added);

This step done, you need to write a php function which will handle this “event” :

  1. <?php function on_meta_boxes_added() {
  2. if (function_exists(‘add_meta_box’)) {
  3.       add_meta_box("divId", "DivName", "write_meta_box_content", "post");
  4.       } else {
  5. ?>
  6. <fieldset id="divId" class="dbx-box">
  7. <h3 class="dbx-handle">DivName</h3>
  8.    <div class="dbx-content">
  9.       <?php echo write_meta_box_content();
  10.    </div>
  11. </fieldset><?php
  12.       }
  13. }
  14. ?>

You just had now to write your own “write_meta_box_content” function.
Of course, using WordPress 2.5+, by adding an “event” to the action “do_meta_boxes” you can add meta-boxes everywhere they are used.

  1. add_action(‘do_meta_boxes’, on_meta_boxes_added, 10, 3);
  2. function on_meta_boxes_added($page, $type, $post) {
  3. echo "$page admin of $type contains $post :) ";
  4. }

Here, as you can see, my admin post page look good now :)

Dzone plugin

For those of you who would like to have the modified plug-in working directly here is the link :

dzone-widget