[wp-trac] [WordPress Trac] #9674: Better support for custom post types
WordPress Trac
wp-trac at lists.automattic.com
Thu Dec 31 00:26:46 UTC 2009
#9674: Better support for custom post types
------------------------------------+---------------------------------------
Reporter: wnorris | Owner: ryan
Type: task (blessed) | Status: reopened
Priority: normal | Milestone: 3.0
Component: Administration | Version: 2.9
Severity: normal | Resolution:
Keywords: has-patch tested early |
------------------------------------+---------------------------------------
Comment(by mikeschinkel):
And for accessing the object's metadata, don't we also get?
{{{
get_object_type_object_type_object()
}}}
Sorry, I just couldn't resist. ;-p
Seriously, "object" is a great term for use inside the code but if you
must, must, must rename it please use "item" or "record."
For that matter, since this really is a big deal why not put up a poll on
Wordpress.org to see what the majority of people think? Maybe we'll learn
that "post" is not so bad. Or maybe we'll learn it is horrible. But why
not verify before making a decision based on all of our (flawed by nature)
biases and assumptions?
'''@ryan''': also can you please speak to the idea of having a standard
way to persist custom post types?
That said, I'd like to propose an additional change to
register_post_type() and that would be to include a filter. Such a filter
would allow a plugin to annotate metadata to any of the core post types or
even post types registered:
{{{
function register_post_type($post_type, $args = array(), $persist=true)
{
global $wp_post_types;
if (!is_array($wp_post_types))
$wp_post_types = array();
$defaults = array('exclude_from_search' => true);
$args = wp_parse_args($args, $defaults);
$post_type = sanitize_user($post_type, true);
$args['name'] = $post_type;
$args = apply_filter('register_post_type',$args);
$wp_post_types[$post_type] = (object) $args;
if (save_post_types())
save_post_types();
}
}}}
For that matter it would also be good to have hooks for save_post_types()
and load_post_types():
{{{
function save_post_types() {
global $wp_post_types;
$wp_post_types = apply_filter('save_post_types',$wp_post_types);
update_option( 'post_types', $wp_post_types );
}
function load_post_types() {
global $wp_post_types;
$wp_post_types = apply_filter('load_post_types',get_option(
'post_types'));
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9674#comment:75>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list