[wp-hackers] Custom Post - implementation specifics
Ptah Dunbar
pt at ptahd.com
Sat Dec 5 07:52:01 UTC 2009
To quote Stephen:
> In a way it's a shame that in Admin we moved away from
> "Action" ("Write". "Edit") menus toward "Thing" ("Posts", "Pages")
> menus, as this makes it more difficult -- or at least more bulky --
> to incorporate custom post types. Where previously it would have
> been intuitive to add a new item or two under "Edit", now to follow
> the existing structure it would be a case of adding a whole new top
> menu for each new Post Type, which would get big pretty quickly.
After custom post types becomes mainstream once 2.9 ships, people are
going to face the hassle of creating admin menus for them. Going back
towards the "Action" type menus will make things A LOT more simpler
and consistent with the WordPress publishing experience. Users
wouldn't have to think twice about which menu they need to click on to
publish content to. They would just click under "Write", and available
post types will be presented as submenu items. This is a major
prerequisite before any administrative features for custom post types
begin.
I think there's a significance difference between adding a custom
plugin page using the menu/ settings API, compared to adding an
administrative page for post types. Reverting back to the old "Action"
type menus makes the writing and editing experience for any post type
consistent with the admin and a lot more scalable. Developers really
only need to customize admin elements belonging to their post type's
write page.
2.9 adds the custom post type functionality in the backend. If we were
to go back to the Action type menus, perhaps extending the
register_post_type function to enable admin features would be more
viable. Something like:
register_post_type( 'articles', array(
'admin' => array( 'Articles', 'write' => array(
'editor',
'excerpt',
'trackbacks',
'custom_fields'
))
));
The first param. in admin args would be the label of the submenu
following what features the write page should have.
register_post_type() would automatically create the submenus under the
"Write" and "Edit" top-level pages and populate that page with the
desired elements. In addition, developers could build additional page
elements using the add_meta_box feature.
This is all that's really needed for adding basic administrative
features for custom post types.
If that's too much abstraction, then consider:
register_post_type( 'articles', array( 'admin' => 'Articles');
Which just creates the write and edit submenus for the Articles post
type, and the developer would need to call the necessary
add_meta_box() functions for their page elements on the write page.
All in all, adding administrative features for custom post types
should be dead simple. The developer shouldn't have to do the same
work required to create custom plugin pages (using the menu API,
settings API, handling option sanitizing, etc.) as those are two
distinct administrative task.
Thoughts?
More information about the wp-hackers
mailing list