Changeset 52232 for trunk/src/wp-admin/site-editor.php
- Timestamp:
- 11/23/2021 05:38:45 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/site-editor.php
r52161 r52232 41 41 42 42 $block_editor_context = new WP_Block_Editor_Context(); 43 $custom_settings = array( 44 'siteUrl' => site_url(), 45 'postsPerPage' => get_option( 'posts_per_page' ), 46 'styles' => get_block_editor_theme_styles(), 47 'defaultTemplateTypes' => get_default_block_template_types(), 48 'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(), 49 '__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(), 50 '__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(), 51 ); 52 $editor_settings = get_block_editor_settings( $custom_settings, $block_editor_context ); 43 53 44 $active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id(); 45 $active_theme = wp_get_theme()->get_stylesheet(); 46 $preload_paths = array( 47 array( '/wp/v2/media', 'OPTIONS' ), 48 '/', 49 '/wp/v2/types?context=edit', 50 '/wp/v2/taxonomies?context=edit', 51 '/wp/v2/pages?context=edit', 52 '/wp/v2/categories?context=edit', 53 '/wp/v2/posts?context=edit', 54 '/wp/v2/tags?context=edit', 55 '/wp/v2/templates?context=edit', 56 '/wp/v2/template-parts?context=edit', 57 '/wp/v2/settings', 58 '/wp/v2/themes?context=edit&status=active', 59 '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', 60 '/wp/v2/global-styles/' . $active_global_styles_id, 61 '/wp/v2/themes/' . $active_theme . '/global-styles', 62 '/wp/v2/block-navigation-areas?context=edit', 63 ); 54 if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) { 64 55 65 $areas = get_option( 'wp_navigation_areas', array() ); 66 $active_areas = array_intersect_key( $areas, get_navigation_areas() ); 67 foreach ( $active_areas as $post_id ) { 68 if ( $post_id ) { 69 $preload_paths[] = add_query_arg( 'context', 'edit', rest_get_route_for_post( $post_id ) ); 56 $post_type = get_post_type_object( $_GET['postType'] ); 57 58 if ( ! $post_type ) { 59 wp_die( __( 'Invalid post type.' ) ); 70 60 } 61 62 $preload_paths = array( 63 '/', 64 '/wp/v2/types/' . $post_type->name . '?context=edit', 65 '/wp/v2/types?context=edit', 66 '/wp/v2/' . $post_type->rest_base . '?context=edit', 67 ); 68 69 block_editor_rest_api_preload( $preload_paths, $block_editor_context ); 70 71 wp_add_inline_script( 72 'wp-edit-site', 73 sprintf( 74 'wp.domReady( function() { 75 wp.editSite.initializeList( "site-editor", "%s", %s ); 76 } );', 77 $post_type->name, 78 wp_json_encode( $editor_settings ) 79 ) 80 ); 81 82 } else { 83 84 $active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id(); 85 $active_theme = wp_get_theme()->get_stylesheet(); 86 $preload_paths = array( 87 array( '/wp/v2/media', 'OPTIONS' ), 88 '/', 89 '/wp/v2/types?context=edit', 90 '/wp/v2/taxonomies?context=edit', 91 '/wp/v2/pages?context=edit', 92 '/wp/v2/categories?context=edit', 93 '/wp/v2/posts?context=edit', 94 '/wp/v2/tags?context=edit', 95 '/wp/v2/templates?context=edit', 96 '/wp/v2/template-parts?context=edit', 97 '/wp/v2/settings', 98 '/wp/v2/themes?context=edit&status=active', 99 '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', 100 '/wp/v2/global-styles/' . $active_global_styles_id, 101 '/wp/v2/themes/' . $active_theme . '/global-styles', 102 '/wp/v2/block-navigation-areas?context=edit', 103 ); 104 105 $areas = get_option( 'wp_navigation_areas', array() ); 106 $active_areas = array_intersect_key( $areas, get_navigation_areas() ); 107 foreach ( $active_areas as $post_id ) { 108 if ( $post_id ) { 109 $preload_paths[] = add_query_arg( 'context', 'edit', rest_get_route_for_post( $post_id ) ); 110 } 111 } 112 113 block_editor_rest_api_preload( $preload_paths, $block_editor_context ); 114 115 wp_add_inline_script( 116 'wp-edit-site', 117 sprintf( 118 'wp.domReady( function() { 119 wp.editSite.initializeEditor( "site-editor", %s ); 120 } );', 121 wp_json_encode( $editor_settings ) 122 ) 123 ); 124 71 125 } 72 73 block_editor_rest_api_preload( $preload_paths, $block_editor_context );74 75 $editor_settings = get_block_editor_settings(76 array(77 'siteUrl' => site_url(),78 'postsPerPage' => get_option( 'posts_per_page' ),79 'styles' => get_block_editor_theme_styles(),80 'defaultTemplateTypes' => get_default_block_template_types(),81 'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),82 '__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),83 '__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),84 ),85 $block_editor_context86 );87 88 wp_add_inline_script(89 'wp-edit-site',90 sprintf(91 'wp.domReady( function() {92 wp.editSite.initialize( "site-editor", %s );93 } );',94 wp_json_encode( $editor_settings )95 )96 );97 126 98 127 // Preload server-registered block schemas.
Note: See TracChangeset
for help on using the changeset viewer.