Ticket #23169: 23169.patch

File 23169.patch, 1.6 KB (added by SergeyBiryukov, 4 months ago)
  • wp-includes/post.php

     
    927927 
    928928        // Args prefixed with an underscore are reserved for internal use. 
    929929        $defaults = array( 
     930                'object_type' => array( 'post', 'page' ), 
    930931                'label' => false, 
    931932                'label_count' => false, 
    932933                'exclude_from_search' => null, 
     
    944945 
    945946        $post_status = sanitize_key($post_status); 
    946947        $args->name = $post_status; 
     948        $args->object_type = array_unique( (array) $args->object_type ); 
    947949 
    948950        if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 
    949951                $args->internal = true; 
     
    984986} 
    985987 
    986988/** 
     989 * Add an already registered post_status to an object type. 
     990 * 
     991 * @package WordPress 
     992 * @subpackage Post 
     993 * @since 3.6.0 
     994 * @uses $wp_post_statuses Modifies post status object 
     995 * 
     996 * @param string $post_status Name of post status object 
     997 * @param string $object_type Name of the object type 
     998 * @return bool True if successful, false if not 
     999 */ 
     1000function register_post_status_for_object_type( $post_status, $object_type ) { 
     1001        global $wp_post_statuses; 
     1002 
     1003        if ( ! isset( $wp_post_statuses[ $post_status ] ) ) 
     1004                return false; 
     1005 
     1006        if ( ! get_post_type_object( $object_type ) ) 
     1007                return false; 
     1008 
     1009        if ( ! in_array( $object_type, $wp_post_statuses[ $post_status ]->object_type ) ) 
     1010                $wp_post_statuses[ $post_status ]->object_type[] = $object_type; 
     1011 
     1012        return true; 
     1013} 
     1014 
     1015/** 
    9871016 * Retrieve a post status object by name 
    9881017 * 
    9891018 * @package WordPress