Ticket #36492: 36492.diff
File 36492.diff, 3.4 KB (added by , 7 years ago) |
---|
-
src/wp-includes/post.php
670 670 * e.g. All (12) | Published (9) | My Custom Status (2) 671 671 * Default is value of $internal. 672 672 * } 673 * @return object673 * @return WP_Post_Status the new post status object 674 674 */ 675 675 function register_post_status( $post_status, $args = array() ) { 676 676 global $wp_post_statuses; … … 678 678 if (!is_array($wp_post_statuses)) 679 679 $wp_post_statuses = array(); 680 680 681 // Args prefixed with an underscore are reserved for internal use. 682 $defaults = array( 683 'label' => false, 684 'label_count' => false, 685 'exclude_from_search' => null, 686 '_builtin' => false, 687 'public' => null, 688 'internal' => null, 689 'protected' => null, 690 'private' => null, 691 'publicly_queryable' => null, 692 'show_in_admin_status_list' => null, 693 'show_in_admin_all_list' => null, 694 ); 695 $args = wp_parse_args($args, $defaults); 696 $args = (object) $args; 681 $post_status_object = new WP_Post_Status( $post_status, $args ); 697 682 698 $post_status = sanitize_key($post_status); 699 $args->name = $post_status; 683 $wp_post_statuses[ $post_status ] = $post_status_object; 700 684 701 // Set various defaults. 702 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 703 $args->internal = true; 704 705 if ( null === $args->public ) 706 $args->public = false; 707 708 if ( null === $args->private ) 709 $args->private = false; 710 711 if ( null === $args->protected ) 712 $args->protected = false; 713 714 if ( null === $args->internal ) 715 $args->internal = false; 716 717 if ( null === $args->publicly_queryable ) 718 $args->publicly_queryable = $args->public; 719 720 if ( null === $args->exclude_from_search ) 721 $args->exclude_from_search = $args->internal; 722 723 if ( null === $args->show_in_admin_all_list ) 724 $args->show_in_admin_all_list = !$args->internal; 725 726 if ( null === $args->show_in_admin_status_list ) 727 $args->show_in_admin_status_list = !$args->internal; 728 729 if ( false === $args->label ) 730 $args->label = $post_status; 731 732 if ( false === $args->label_count ) 733 $args->label_count = array( $args->label, $args->label ); 734 735 $wp_post_statuses[$post_status] = $args; 736 737 return $args; 685 return $post_status_object; 738 686 } 739 687 740 688 /** … … 747 695 * @see register_post_status() 748 696 * 749 697 * @param string $post_status The name of a registered post status. 750 * @return object|null A post status object.698 * @return WP_Post_Status|null A post status object. 751 699 */ 752 700 function get_post_status_object( $post_status ) { 753 global $wp_post_statuses; 754 755 if ( empty($wp_post_statuses[$post_status]) ) 756 return null; 757 758 return $wp_post_statuses[$post_status]; 701 return WP_Post_Status::get_instance( $post_status ); 759 702 } 760 703 761 704 /** -
src/wp-settings.php
142 142 require( ABSPATH . WPINC . '/post.php' ); 143 143 require( ABSPATH . WPINC . '/class-walker-page.php' ); 144 144 require( ABSPATH . WPINC . '/class-walker-page-dropdown.php' ); 145 require( ABSPATH . WPINC . '/class-wp-post-status.php' ); 145 146 require( ABSPATH . WPINC . '/class-wp-post.php' ); 146 147 require( ABSPATH . WPINC . '/post-template.php' ); 147 148 require( ABSPATH . WPINC . '/revision.php' );