Ticket #38323: wp-object-type.diff
File wp-object-type.diff, 4.3 KB (added by , 6 years ago) |
---|
-
src/wp-includes/class-wp-object-type.php
1 <?php 2 /** 3 * Object Type API: WP_Object_Type class 4 * 5 * @package WordPress 6 * @subpackage Object 7 * @since 4.8.0 8 */ 9 10 /** 11 * Core class used for interacting with object types. 12 * 13 * @since 4.8.0 14 */ 15 class WP_Object_Type { 16 /** 17 * Object type name. 18 * 19 * @since 4.8.0 20 * @access protected 21 * @var string 22 */ 23 protected $object_type = ''; 24 25 /** 26 * Object type instances. 27 * 28 * @since 4.8.0 29 * @access protected 30 * @static 31 * @var array 32 */ 33 protected static $instances = array(); 34 35 /** 36 * Constructor. 37 * 38 * @since 4.8.0 39 * @access public 40 * 41 * @param string $object_type Object type name. 42 */ 43 public function __construct( $object_type ) { 44 $this->object_type = $object_type; 45 } 46 47 /** 48 * Returns the object type name. 49 * 50 * @since 4.8.0 51 * @access public 52 * 53 * @return string Object type name. 54 */ 55 public function get_object_type() { 56 return $this->object_type; 57 } 58 59 /** 60 * Returns the subtype name. 61 * 62 * @since 4.8.0 63 * @access public 64 * 65 * @return string Subtype name, or empty string if no subtype set. 66 */ 67 public function get_subtype() { 68 if ( ! isset( $this->name ) ) { 69 return ''; 70 } 71 72 return $this->name; 73 } 74 75 /** 76 * Returns an general object type instance. 77 * 78 * @since 4.8.0 79 * @access public 80 * @static 81 * 82 * @param string $object_type Object type name. 83 * @return WP_Object_Type|null Object type instance, or null if invalid object type. 84 */ 85 public static function get_instance( $object_type ) { 86 if ( ! in_array( $object_type, array( 'post', 'term', 'comment', 'user' ), true ) ) { 87 return null; 88 } 89 90 if ( ! isset( self::$instances[ $object_type ] ) ) { 91 self::$instances[ $object_type ] = new self( $object_type ); 92 } 93 94 return self::$instances[ $object_type ]; 95 } 96 } -
src/wp-includes/class-wp-post-type.php
Property changes on: src/wp-includes/class-wp-object-type.php ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
11 11 * Core class used for interacting with post types. 12 12 * 13 13 * @since 4.6.0 14 * @since 4.8.0 Now inherits WP_Object_Type. 14 15 * 15 16 * @see register_post_type() 16 17 */ 17 final class WP_Post_Type {18 final class WP_Post_Type extends WP_Object_Type { 18 19 /** 19 20 * Post type key. 20 21 * … … 381 382 * Default empty array. 382 383 */ 383 384 public function __construct( $post_type, $args = array() ) { 385 parent::__construct( 'post' ); 386 384 387 $this->name = $post_type; 385 388 386 389 $this->set_props( $args ); -
src/wp-includes/class-wp-taxonomy.php
11 11 * Core class used for interacting with taxonomies. 12 12 * 13 13 * @since 4.7.0 14 * @since 4.8.0 Now inherits WP_Object_Type. 14 15 */ 15 final class WP_Taxonomy {16 final class WP_Taxonomy extends WP_Object_Type { 16 17 /** 17 18 * Taxonomy key. 18 19 * … … 241 242 * Default empty array. 242 243 */ 243 244 public function __construct( $taxonomy, $object_type, $args = array() ) { 245 parent::__construct( 'term' ); 246 244 247 $this->name = $taxonomy; 245 248 246 249 $this->set_props( $object_type, $args ); -
src/wp-settings.php
145 145 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' ); 146 146 require( ABSPATH . WPINC . '/formatting.php' ); 147 147 require( ABSPATH . WPINC . '/capabilities.php' ); 148 require( ABSPATH . WPINC . '/class-wp-object-type.php' ); 148 149 require( ABSPATH . WPINC . '/class-wp-roles.php' ); 149 150 require( ABSPATH . WPINC . '/class-wp-role.php' ); 150 151 require( ABSPATH . WPINC . '/class-wp-user.php' );