[wp-trac] [WordPress Trac] #12567: make post_submit_meta_box more generic

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 30 06:33:09 UTC 2010


#12567: make post_submit_meta_box more generic
---------------------------+------------------------------------------------
 Reporter:  themattharris  |       Owner:                                                                    
     Type:  enhancement    |      Status:  new                                                               
 Priority:  normal         |   Milestone:  Future Release                                                    
Component:  Post Types     |     Version:                                                                    
 Severity:  normal         |    Keywords:  post_status, register_post_status, post_submit_meta_box, metaboxes
---------------------------+------------------------------------------------

Comment(by johnkolbert):

 Ok, I'm attaching the latest diff. Here's the files I've edited:

 wp-includes/post.php[[BR]]
 wp-includes/script-loader.php[[BR]]
 wp-admin/includes/template.php[[BR]]
 wp-admin/includes/meta-boxes.php[[BR]]
 wp-admin/js/post.dev.js (haven't added changes to post.js yet)

 For anyone who cares, and partly for my own review, I'm going go through
 the changes I've made. I'm sure there will be a few bugs and some more
 work that needs to be done to get this working, but this is what I've got
 so far.


 == File: post.php ==

 I added four arguments to `register_post_status()`: `post_type`,
 `edit_cap`, `show_in_select_ui`, & `display_label`

 `post_type`: holds an array of post types that the status can be
 explicitly declared to. Defaults to 'false', which means its available for
 all post types[[BR]]
 `edit_cap`: changing the post status can be limited by capability. If set,
 users must have the declared capability to change change posts to this
 capability. Defaults to NULL[[BR]]
 `show_in_select_ui`: is set to `true`, the status is displayed in the
 select boxes on `edit.php` and `post-new.php`. Defaults to `false`
 `display_label`: an additional label that can be used in the select box.
 Defaults to `label` or the status name

 I also created a new function: `post_type_can_have_status($post_type,
 $status)`[[BR]]
 This function takes a post type and a status and returns `true`if the
 status is available for that post type

 I added a new argument to `register_post_type()`: `allowed_status`

 `allowed_status`: holds an array of status names that are allowed for the
 registered post type. If set, only these status types will be allowed for
 this post type. Defaults to `false`, meaning it uses the default post
 types.

 == File: meta-boxes.php ==

 I adjusted the submit box to check if the post type handles specific
 statuses, and only shows what is appropriate. The status dropdown now
 shows statuses that have either assigned to the post type or the default
 statuses. May need some tweaking.

 == File: template.php ==

 Added a helper function `output_post_status_select()`, which echos the
 available post types as option values for the select boxes.

 Modified the inline editor of `inline_edit_row()` to use the helper
 function

 == File: script-loader.php & post.dev.js ==

 Altered the javascript to handle the new post types. Still needs some work

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


More information about the wp-trac mailing list