@@ -26,46 +26,48 @@ function create_initial_post_types() {
26
26
'labels ' => array (
27
27
'name_admin_bar ' => _x ( 'Post ' , 'add new from admin bar ' ),
28
28
),
29
- 'public ' => true ,
30
- '_builtin ' => true , /* internal use only. don't use this when registering your own post type. */
31
- '_edit_link ' => 'post.php?post=%d ' , /* internal use only. don't use this when registering your own post type. */
32
- 'capability_type ' => 'post ' ,
33
- 'map_meta_cap ' => true ,
34
- 'menu_position ' => 5 ,
35
- 'menu_icon ' => 'dashicons-admin-post ' ,
36
- 'hierarchical ' => false ,
37
- 'rewrite ' => false ,
38
- 'query_var ' => false ,
39
- 'delete_with_user ' => true ,
40
- 'supports ' => array ( 'title ' , 'editor ' , 'author ' , 'thumbnail ' , 'excerpt ' , 'trackbacks ' , 'custom-fields ' , 'comments ' , 'revisions ' , 'post-formats ' ),
41
- 'show_in_rest ' => true ,
42
- 'rest_base ' => 'posts ' ,
43
- 'rest_controller_class ' => 'WP_REST_Posts_Controller ' ,
29
+ 'public ' => true ,
30
+ '_builtin ' => true , /* internal use only. don't use this when registering your own post type. */
31
+ '_edit_link ' => 'post.php?post=%d ' , /* internal use only. don't use this when registering your own post type. */
32
+ 'capability_type ' => 'post ' ,
33
+ 'map_meta_cap ' => true ,
34
+ 'menu_position ' => 5 ,
35
+ 'menu_icon ' => 'dashicons-admin-post ' ,
36
+ 'hierarchical ' => false ,
37
+ 'rewrite ' => false ,
38
+ 'query_var ' => false ,
39
+ 'delete_with_user ' => true ,
40
+ 'supports ' => array ( 'title ' , 'editor ' , 'author ' , 'thumbnail ' , 'excerpt ' , 'trackbacks ' , 'custom-fields ' , 'comments ' , 'revisions ' , 'post-formats ' ),
41
+ 'show_in_rest ' => true ,
42
+ 'rest_base ' => 'posts ' ,
43
+ 'rest_controller_class ' => 'WP_REST_Posts_Controller ' ,
44
+ 'default_rendering_mode ' => 'post-only ' ,
44
45
)
45
46
);
46
47
47
48
register_post_type (
48
49
'page ' ,
49
50
array (
50
- 'labels ' => array (
51
+ 'labels ' => array (
51
52
'name_admin_bar ' => _x ( 'Page ' , 'add new from admin bar ' ),
52
53
),
53
- 'public ' => true ,
54
- 'publicly_queryable ' => false ,
55
- '_builtin ' => true , /* internal use only. don't use this when registering your own post type. */
56
- '_edit_link ' => 'post.php?post=%d ' , /* internal use only. don't use this when registering your own post type. */
57
- 'capability_type ' => 'page ' ,
58
- 'map_meta_cap ' => true ,
59
- 'menu_position ' => 20 ,
60
- 'menu_icon ' => 'dashicons-admin-page ' ,
61
- 'hierarchical ' => true ,
62
- 'rewrite ' => false ,
63
- 'query_var ' => false ,
64
- 'delete_with_user ' => true ,
65
- 'supports ' => array ( 'title ' , 'editor ' , 'author ' , 'thumbnail ' , 'page-attributes ' , 'custom-fields ' , 'comments ' , 'revisions ' ),
66
- 'show_in_rest ' => true ,
67
- 'rest_base ' => 'pages ' ,
68
- 'rest_controller_class ' => 'WP_REST_Posts_Controller ' ,
54
+ 'public ' => true ,
55
+ 'publicly_queryable ' => false ,
56
+ '_builtin ' => true , /* internal use only. don't use this when registering your own post type. */
57
+ '_edit_link ' => 'post.php?post=%d ' , /* internal use only. don't use this when registering your own post type. */
58
+ 'capability_type ' => 'page ' ,
59
+ 'map_meta_cap ' => true ,
60
+ 'menu_position ' => 20 ,
61
+ 'menu_icon ' => 'dashicons-admin-page ' ,
62
+ 'hierarchical ' => true ,
63
+ 'rewrite ' => false ,
64
+ 'query_var ' => false ,
65
+ 'delete_with_user ' => true ,
66
+ 'supports ' => array ( 'title ' , 'editor ' , 'author ' , 'thumbnail ' , 'page-attributes ' , 'custom-fields ' , 'comments ' , 'revisions ' ),
67
+ 'show_in_rest ' => true ,
68
+ 'rest_base ' => 'pages ' ,
69
+ 'rest_controller_class ' => 'WP_REST_Posts_Controller ' ,
70
+ 'default_rendering_mode ' => 'template-lock ' ,
69
71
)
70
72
);
71
73
@@ -2326,6 +2328,25 @@ function get_post_types_by_support( $feature, $operator = 'and' ) {
2326
2328
return array_keys ( wp_filter_object_list ( $ _wp_post_type_features , $ features , $ operator ) );
2327
2329
}
2328
2330
2331
+ /**
2332
+ * Get the available rendering modes for the Block Editor.
2333
+ *
2334
+ * post-only: This mode extracts the post blocks from the template and renders only those.
2335
+ * The idea is to allow the user to edit the post/page in isolation without the wrapping template.
2336
+ *
2337
+ * template-locked: This mode renders both the template and the post blocks
2338
+ * but the template blocks are locked and can't be edited. The post blocks are editable.
2339
+ *
2340
+ * @return array Array of available rendering modes.
2341
+ */
2342
+ function get_post_type_rendering_modes () {
2343
+ return array (
2344
+ 'post-only ' ,
2345
+ 'template-lock ' ,
2346
+ 'template-locked ' ,
2347
+ );
2348
+ }
2349
+
2329
2350
/**
2330
2351
* Updates the post type for the post ID.
2331
2352
*
0 commit comments