wp/wp-includes/class-wp-post-type.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    38 	 * and page labels for hierarchical ones.
    38 	 * and page labels for hierarchical ones.
    39 	 *
    39 	 *
    40 	 * @see get_post_type_labels()
    40 	 * @see get_post_type_labels()
    41 	 *
    41 	 *
    42 	 * @since 4.6.0
    42 	 * @since 4.6.0
    43 	 * @var object $labels
    43 	 * @var stdClass $labels
    44 	 */
    44 	 */
    45 	public $labels;
    45 	public $labels;
    46 
    46 
    47 	/**
    47 	/**
    48 	 * A short descriptive summary of what the post type is.
    48 	 * A short descriptive summary of what the post type is.
   121 	 * will be placed as a sub-menu of that.
   121 	 * will be placed as a sub-menu of that.
   122 	 *
   122 	 *
   123 	 * Default is the value of $show_ui.
   123 	 * Default is the value of $show_ui.
   124 	 *
   124 	 *
   125 	 * @since 4.6.0
   125 	 * @since 4.6.0
   126 	 * @var bool $show_in_menu
   126 	 * @var bool|string $show_in_menu
   127 	 */
   127 	 */
   128 	public $show_in_menu = null;
   128 	public $show_in_menu = null;
   129 
   129 
   130 	/**
   130 	/**
   131 	 * Makes this post type available for selection in navigation menus.
   131 	 * Makes this post type available for selection in navigation menus.
   156 	 * @var int $menu_position
   156 	 * @var int $menu_position
   157 	 */
   157 	 */
   158 	public $menu_position = null;
   158 	public $menu_position = null;
   159 
   159 
   160 	/**
   160 	/**
   161 	 * The URL to the icon to be used for this menu.
   161 	 * The URL or reference to the icon to be used for this menu.
   162 	 *
   162 	 *
   163 	 * Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme.
   163 	 * Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme.
   164 	 * This should begin with 'data:image/svg+xml;base64,'. Pass the name of a Dashicons helper class
   164 	 * This should begin with 'data:image/svg+xml;base64,'. Pass the name of a Dashicons helper class
   165 	 * to use a font icon, e.g. 'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
   165 	 * to use a font icon, e.g. 'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
   166 	 * so an icon can be added via CSS.
   166 	 * so an icon can be added via CSS.
   248 	public $can_export = true;
   248 	public $can_export = true;
   249 
   249 
   250 	/**
   250 	/**
   251 	 * Whether to delete posts of this type when deleting a user.
   251 	 * Whether to delete posts of this type when deleting a user.
   252 	 *
   252 	 *
   253 	 * If true, posts of this type belonging to the user will be moved to Trash when then user is deleted.
   253 	 * - If true, posts of this type belonging to the user will be moved to Trash when the user is deleted.
   254 	 * If false, posts of this type belonging to the user will *not* be trashed or deleted.
   254 	 * - If false, posts of this type belonging to the user will *not* be trashed or deleted.
   255 	 * If not set (the default), posts are trashed if post_type_supports( 'author' ).
   255 	 * - If not set (the default), posts are trashed if post type supports the 'author' feature.
   256 	 * Otherwise posts are not trashed or deleted. Default null.
   256 	 *   Otherwise posts are not trashed or deleted.
       
   257 	 *
       
   258 	 * Default null.
   257 	 *
   259 	 *
   258 	 * @since 4.6.0
   260 	 * @since 4.6.0
   259 	 * @var bool $delete_with_user
   261 	 * @var bool $delete_with_user
   260 	 */
   262 	 */
   261 	public $delete_with_user = null;
   263 	public $delete_with_user = null;
   262 
   264 
   263 	/**
   265 	/**
       
   266 	 * Array of blocks to use as the default initial state for an editor session.
       
   267 	 *
       
   268 	 * Each item should be an array containing block name and optional attributes.
       
   269 	 *
       
   270 	 * Default empty array.
       
   271 	 *
       
   272 	 * @link https://developer.wordpress.org/block-editor/developers/block-api/block-templates/
       
   273 	 *
       
   274 	 * @since 5.0.0
       
   275 	 * @var array $template
       
   276 	 */
       
   277 	public $template = array();
       
   278 
       
   279 	/**
       
   280 	 * Whether the block template should be locked if $template is set.
       
   281 	 *
       
   282 	 * - If set to 'all', the user is unable to insert new blocks, move existing blocks
       
   283 	 *   and delete blocks.
       
   284 	 * - If set to 'insert', the user is able to move existing blocks but is unable to insert
       
   285 	 *   new blocks and delete blocks.
       
   286 	 *
       
   287 	 * Default false.
       
   288 	 *
       
   289 	 * @link https://developer.wordpress.org/block-editor/developers/block-api/block-templates/
       
   290 	 *
       
   291 	 * @since 5.0.0
       
   292 	 * @var string|false $template_lock
       
   293 	 */
       
   294 	public $template_lock = false;
       
   295 
       
   296 	/**
   264 	 * Whether this post type is a native or "built-in" post_type.
   297 	 * Whether this post type is a native or "built-in" post_type.
   265 	 *
   298 	 *
   266 	 * Default false.
   299 	 * Default false.
   267 	 *
   300 	 *
   268 	 * @since 4.6.0
   301 	 * @since 4.6.0
   282 
   315 
   283 	/**
   316 	/**
   284 	 * Post type capabilities.
   317 	 * Post type capabilities.
   285 	 *
   318 	 *
   286 	 * @since 4.6.0
   319 	 * @since 4.6.0
   287 	 * @var object $cap
   320 	 * @var stdClass $cap
   288 	 */
   321 	 */
   289 	public $cap;
   322 	public $cap;
   290 
   323 
   291 	/**
   324 	/**
   292 	 * Triggers the handling of rewrites for this post type.
   325 	 * Triggers the handling of rewrites for this post type.
   345 	 */
   378 	 */
   346 	public $rest_controller;
   379 	public $rest_controller;
   347 
   380 
   348 	/**
   381 	/**
   349 	 * Constructor.
   382 	 * Constructor.
       
   383 	 *
       
   384 	 * See the register_post_type() function for accepted arguments for `$args`.
   350 	 *
   385 	 *
   351 	 * Will populate object properties from the provided arguments and assign other
   386 	 * Will populate object properties from the provided arguments and assign other
   352 	 * default properties based on that information.
   387 	 * default properties based on that information.
   353 	 *
   388 	 *
   354 	 * @since 4.6.0
   389 	 * @since 4.6.0
   365 		$this->set_props( $args );
   400 		$this->set_props( $args );
   366 	}
   401 	}
   367 
   402 
   368 	/**
   403 	/**
   369 	 * Sets post type properties.
   404 	 * Sets post type properties.
       
   405 	 *
       
   406 	 * See the register_post_type() function for accepted arguments for `$args`.
   370 	 *
   407 	 *
   371 	 * @since 4.6.0
   408 	 * @since 4.6.0
   372 	 *
   409 	 *
   373 	 * @param array|string $args Array or string of arguments for registering a post type.
   410 	 * @param array|string $args Array or string of arguments for registering a post type.
   374 	 */
   411 	 */
   379 		 * Filters the arguments for registering a post type.
   416 		 * Filters the arguments for registering a post type.
   380 		 *
   417 		 *
   381 		 * @since 4.4.0
   418 		 * @since 4.4.0
   382 		 *
   419 		 *
   383 		 * @param array  $args      Array of arguments for registering a post type.
   420 		 * @param array  $args      Array of arguments for registering a post type.
       
   421 		 *                          See the register_post_type() function for accepted arguments.
   384 		 * @param string $post_type Post type key.
   422 		 * @param string $post_type Post type key.
   385 		 */
   423 		 */
   386 		$args = apply_filters( 'register_post_type_args', $args, $this->name );
   424 		$args = apply_filters( 'register_post_type_args', $args, $this->name );
   387 
   425 
   388 		$has_edit_link = ! empty( $args['_edit_link'] );
   426 		$has_edit_link = ! empty( $args['_edit_link'] );
   413 			'can_export'            => true,
   451 			'can_export'            => true,
   414 			'delete_with_user'      => null,
   452 			'delete_with_user'      => null,
   415 			'show_in_rest'          => false,
   453 			'show_in_rest'          => false,
   416 			'rest_base'             => false,
   454 			'rest_base'             => false,
   417 			'rest_controller_class' => false,
   455 			'rest_controller_class' => false,
       
   456 			'template'              => array(),
       
   457 			'template_lock'         => false,
   418 			'_builtin'              => false,
   458 			'_builtin'              => false,
   419 			'_edit_link'            => 'post.php?post=%d',
   459 			'_edit_link'            => 'post.php?post=%d',
   420 		);
   460 		);
   421 
   461 
   422 		$args = array_merge( $defaults, $args );
   462 		$args = array_merge( $defaults, $args );