[wp-hackers] Improving Meta Box Handling
Michael Pretty
mpretty at voceconnect.com
Tue Jun 1 15:18:39 UTC 2010
On 6/1/10 9:21 AM, Otto wrote:
> 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.
>
Yes, but most plugins don't call add_meta_box until the 'do_metaboxes'
action, which makes it difficult for plugins that add post types to see
what meta handlers are available.
>
>> -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.
>
If you're able to register a save meta callback instead of having to
work off of the save_post action, plugin authors no longer have to worry
about checking against all of these before updating the meta value.
>
>> -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?
>
Yes, but the idea is to reduce the amount of code needed for a plugin to
add a meta handler.
As the title states, the goal is to improve the meta box api. All of
this has work-arounds, but so did creating multiple instance sidebar
widgets and custom post types. WordPress is popular because it's both
simple to use and simple to modify.
More information about the wp-hackers
mailing list