[wp-hackers] Improving Meta Box Handling

Otto otto at ottodestruct.com
Tue Jun 1 13:21:34 UTC 2010


On Mon, May 31, 2010 at 8:53 PM, Michael Pretty <mpretty at voceconnect.com> wrote:
> Now that the first release candidate for WP 3.0 is out, I wanted to get the
> ball rolling on a ticket I submitted for 3.1,
> http://core.trac.wordpress.org/ticket/12450.  The idea behind the ticket is
> to improve and simplify the api for meta boxes.  Some of the ideas I had for
> improvement are:
....

All this is pretty much already there, isn't it? Let's run the list:

> -a registration like that of taxonomies and post types so that plugins can
> optionally apply those to any post types they add.

The fourth parameter of add_meta_box is the post type that the meta
box will appear on.

> -an update callback registration, to simplify the checks a developer has to
> make against revision, AJAX, AUTOSAVE, etc.

While these could indeed be simplified, I don't quite see how you'd
make a callback mechanism work any better than a simple if statement.

> -transition built in meta boxes (excerpt, comments, publish, etc) to use new
> registration.

Goes without saying that you'd move existing things over.

> -add handling to optionally check against capability before displaying meta
> box based on registration.

You can do a capability check before calling add_meta_box, can't you?

This may be a good idea, but I didn't think meta boxes were all that
complicated to begin with. Can you give some examples of how this sort
of thing would be easier than the existing code?

-Otto


More information about the wp-hackers mailing list