420 * @param array $args Array of arguments for registering a post type. |
437 * @param array $args Array of arguments for registering a post type. |
421 * See the register_post_type() function for accepted arguments. |
438 * See the register_post_type() function for accepted arguments. |
422 * @param string $post_type Post type key. |
439 * @param string $post_type Post type key. |
423 */ |
440 */ |
424 $args = apply_filters( 'register_post_type_args', $args, $this->name ); |
441 $args = apply_filters( 'register_post_type_args', $args, $this->name ); |
|
442 |
|
443 $post_type = $this->name; |
|
444 |
|
445 /** |
|
446 * Filters the arguments for registering a specific post type. |
|
447 * |
|
448 * The dynamic portion of the filter name, `$post_type`, refers to the post type key. |
|
449 * |
|
450 * Possible hook names include: |
|
451 * |
|
452 * - `register_post_post_type_args` |
|
453 * - `register_page_post_type_args` |
|
454 * |
|
455 * @since 6.0.0 |
|
456 * |
|
457 * @param array $args Array of arguments for registering a post type. |
|
458 * See the register_post_type() function for accepted arguments. |
|
459 * @param string $post_type Post type key. |
|
460 */ |
|
461 $args = apply_filters( "register_{$post_type}_post_type_args", $args, $this->name ); |
425 |
462 |
426 $has_edit_link = ! empty( $args['_edit_link'] ); |
463 $has_edit_link = ! empty( $args['_edit_link'] ); |
427 |
464 |
428 // Args prefixed with an underscore are reserved for internal use. |
465 // Args prefixed with an underscore are reserved for internal use. |
429 $defaults = array( |
466 $defaults = array( |
450 'query_var' => true, |
487 'query_var' => true, |
451 'can_export' => true, |
488 'can_export' => true, |
452 'delete_with_user' => null, |
489 'delete_with_user' => null, |
453 'show_in_rest' => false, |
490 'show_in_rest' => false, |
454 'rest_base' => false, |
491 'rest_base' => false, |
|
492 'rest_namespace' => false, |
455 'rest_controller_class' => false, |
493 'rest_controller_class' => false, |
456 'template' => array(), |
494 'template' => array(), |
457 'template_lock' => false, |
495 'template_lock' => false, |
458 '_builtin' => false, |
496 '_builtin' => false, |
459 '_edit_link' => 'post.php?post=%d', |
497 '_edit_link' => 'post.php?post=%d', |
768 return null; |
811 return null; |
769 } |
812 } |
770 |
813 |
771 return $this->rest_controller; |
814 return $this->rest_controller; |
772 } |
815 } |
|
816 |
|
817 /** |
|
818 * Returns the default labels for post types. |
|
819 * |
|
820 * @since 6.0.0 |
|
821 * |
|
822 * @return (string|null)[][] The default labels for post types. |
|
823 */ |
|
824 public static function get_default_labels() { |
|
825 if ( ! empty( self::$default_labels ) ) { |
|
826 return self::$default_labels; |
|
827 } |
|
828 |
|
829 self::$default_labels = array( |
|
830 'name' => array( _x( 'Posts', 'post type general name' ), _x( 'Pages', 'post type general name' ) ), |
|
831 'singular_name' => array( _x( 'Post', 'post type singular name' ), _x( 'Page', 'post type singular name' ) ), |
|
832 'add_new' => array( _x( 'Add New', 'post' ), _x( 'Add New', 'page' ) ), |
|
833 'add_new_item' => array( __( 'Add New Post' ), __( 'Add New Page' ) ), |
|
834 'edit_item' => array( __( 'Edit Post' ), __( 'Edit Page' ) ), |
|
835 'new_item' => array( __( 'New Post' ), __( 'New Page' ) ), |
|
836 'view_item' => array( __( 'View Post' ), __( 'View Page' ) ), |
|
837 'view_items' => array( __( 'View Posts' ), __( 'View Pages' ) ), |
|
838 'search_items' => array( __( 'Search Posts' ), __( 'Search Pages' ) ), |
|
839 'not_found' => array( __( 'No posts found.' ), __( 'No pages found.' ) ), |
|
840 'not_found_in_trash' => array( __( 'No posts found in Trash.' ), __( 'No pages found in Trash.' ) ), |
|
841 'parent_item_colon' => array( null, __( 'Parent Page:' ) ), |
|
842 'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ), |
|
843 'archives' => array( __( 'Post Archives' ), __( 'Page Archives' ) ), |
|
844 'attributes' => array( __( 'Post Attributes' ), __( 'Page Attributes' ) ), |
|
845 'insert_into_item' => array( __( 'Insert into post' ), __( 'Insert into page' ) ), |
|
846 'uploaded_to_this_item' => array( __( 'Uploaded to this post' ), __( 'Uploaded to this page' ) ), |
|
847 'featured_image' => array( _x( 'Featured image', 'post' ), _x( 'Featured image', 'page' ) ), |
|
848 'set_featured_image' => array( _x( 'Set featured image', 'post' ), _x( 'Set featured image', 'page' ) ), |
|
849 'remove_featured_image' => array( _x( 'Remove featured image', 'post' ), _x( 'Remove featured image', 'page' ) ), |
|
850 'use_featured_image' => array( _x( 'Use as featured image', 'post' ), _x( 'Use as featured image', 'page' ) ), |
|
851 'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ), |
|
852 'filter_by_date' => array( __( 'Filter by date' ), __( 'Filter by date' ) ), |
|
853 'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ), |
|
854 'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ), |
|
855 'item_published' => array( __( 'Post published.' ), __( 'Page published.' ) ), |
|
856 'item_published_privately' => array( __( 'Post published privately.' ), __( 'Page published privately.' ) ), |
|
857 'item_reverted_to_draft' => array( __( 'Post reverted to draft.' ), __( 'Page reverted to draft.' ) ), |
|
858 'item_scheduled' => array( __( 'Post scheduled.' ), __( 'Page scheduled.' ) ), |
|
859 'item_updated' => array( __( 'Post updated.' ), __( 'Page updated.' ) ), |
|
860 'item_link' => array( |
|
861 _x( 'Post Link', 'navigation link block title' ), |
|
862 _x( 'Page Link', 'navigation link block title' ), |
|
863 ), |
|
864 'item_link_description' => array( |
|
865 _x( 'A link to a post.', 'navigation link block description' ), |
|
866 _x( 'A link to a page.', 'navigation link block description' ), |
|
867 ), |
|
868 ); |
|
869 |
|
870 return self::$default_labels; |
|
871 } |
|
872 |
|
873 /** |
|
874 * Resets the cache for the default labels. |
|
875 * |
|
876 * @since 6.0.0 |
|
877 */ |
|
878 public static function reset_default_labels() { |
|
879 self::$default_labels = array(); |
|
880 } |
773 } |
881 } |