[wp-trac] [WordPress Trac] #17447: Add register_post_type and pre_register_post_type hooks

WordPress Trac wp-trac at lists.automattic.com
Tue May 17 04:32:17 UTC 2011


#17447: Add register_post_type and pre_register_post_type hooks
------------------------------------+------------------------------
 Reporter:  mikeschinkel            |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Post Types              |     Version:  3.1
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+------------------------------

Comment (by mikeschinkel):

 Replying to [comment:1 scribu]:
 > what's wrong with add_post_type_support() ?

 Red-faced, didn't know about `add_post_type_support()`.

 However, that function doesn't allow me to intercept all `$args` passed to
 `register_post_type()` and change some of them before the
 `register_post_type()` operates on the `$args`. One example would be to
 set `$args->rewrite = false;` for all post types using a
 `pre_register_post_type` hook, and then define the rewrites differently
 using the `register_post_type` hook; this is exactly something I need
 right now for a project I'm working on.

 A plugin developer may want to provide alternate rules for post type
 archives so it might want to set `$args->has_archive = false;` using a
 `pre_register_post_type` hook, and then define the post type archives
 differently using the `register_post_type` hook. This is also something I
 need.

 In addition I may want to provide an admin console option that allows the
 end user to define all the visibility settings for the different post
 types; a `pre_register_post_type` hook would enable that.

 Another example is`$args->columns` which would include a keyed array of
 headers and callbacks and/or  `$args->column_headers` containing an array
 of headers and `$args->column_callbacks` containing an array of callbacks.

 And yet another example would be to add `$args->meta_boxes` which would
 include a keyed array of `meta_box` args.

 And those examples are all the ones I currently would like to add support
 for, some to make it easier to define a full-features custom post type and
 some to keep WordPress from doing work that I'm simply going to throw
 away.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17447#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list