[wp-trac] [WordPress Trac] #12706: Custom post status bugs in the admin

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 15 05:08:00 UTC 2010


#12706: Custom post status bugs in the admin
----------------------------+-----------------------------------------------
 Reporter:  ptahdunbar      |       Owner:  ptahdunbar 
     Type:  task (blessed)  |      Status:  new        
 Priority:  normal          |   Milestone:  3.1        
Component:  Post Types      |     Version:             
 Severity:  normal          |    Keywords:  needs-patch
----------------------------+-----------------------------------------------

Comment(by kevinB):

 Just updated the
 [http://core.trac.wordpress.org/attachment/ticket/12706/Custom_Stati_Support.patch
 patch] and [http://core.trac.wordpress.org/attachment/ticket/12706/custom-
 status-helper_1.1.zip demo plugin] to:

  * support type-specific status registration
  * fully support custom public stati in the post edit UI, Edit Posts
 listing and everywhere else
  * support scheduled publishing to any public or private status.
 Previously, selection of private visibility forced post to be published
 immediately despite selection (and storage) of future date

 Type-specific stati (governed by $status_obj->object_type array) can be
 registered in two ways:

  * register_post_status now supports object_type in $args array; registers
 the status to all object types by default
  * register_status_for_object_type( $post_status, $object_type ) - Add an
 already registered post status to an object type

 Enforcement is via
 {{{
 // $post_type may be an individual value or an array
 $private_stati = get_post_stati( array( 'object_type' => $post_type,
 'private' => true ) );
 }}}

 To make that work, I had to modify function wp_list_filter to support the
 array value intersection:

 {{{
 function wp_list_filter( $list, $args = array(), $operator = 'and' ) {
         if ( empty( $args ) )
                 return $list;

         $count = count( $args );

         $filtered = array();

         foreach ( $list as $key => $obj ) {
                 $matched = array_intersect_assoc( (array) $obj, $args );

                 foreach( array_keys( $matched ) as $_key ) {
                         if ( is_array( $args[$_key] ) ) {
                                 if ( ! array_intersect( $args[$_key],
 $matched[$_key] ) )
                                         unset( $matched[$_key] );
                         }
                 }

                 $num_matched = count( $matched );

                 if ( ( 'and' == $operator && $num_matched == $count ) || (
 'or' == $operator && $num_matched ) ) {
                         $filtered[$key] = $obj;
                 }
         }

         return $filtered;
 }
 }}}

 get_post_stati() and get_taxonomies() cast object_type argument to array
 to ensure the special treatment.

 Please let me know what needs further explanation.

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


More information about the wp-trac mailing list