PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/pages/dashboard/page-wp-admin.php +37 -13 23.4.0 → 24.1.0 View file →
@@ -86,11 +86,12 @@
86 86 * Automatically called during page rendering.
87 87 */
88 88 function gutenberg_dashboard_wp_admin_preload_data() {
89 89 // Define paths to preload - same for all pages
90 - // Please also change packages/core-data/src/entities.js when changing this.
90 + // This must exactly match the _fields list in packages/core-data/src/entities.js,
91 + // same fields in the same order, or the preload is never consumed.
91 92 $preload_paths = array(
92 - '/?_fields=description,gmt_offset,home,image_sizes,image_size_threshold,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front',
93 + '/?_fields=description,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front',
93 94 array( '/wp/v2/settings', 'OPTIONS' ),
94 95 );
95 96
96 97 // Use rest_preload_api_request to gather the preloaded data
@@ -144,10 +145,14 @@
144 145
145 146 // Get all registered routes
146 147 $routes = gutenberg_get_dashboard_wp_admin_routes();
147 148
148 - // Get boot module asset file for dependencies
149 + // Get boot module asset file for dependencies. Plugins that build their own
150 + // boot module use it; everyone else falls back to the copy bundled with Core.
149 151 $asset_file = __DIR__ . '/../../modules/boot/index.min.asset.php';
152 + if ( ! file_exists( $asset_file ) ) {
153 + $asset_file = ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php';
154 + }
150 155 if ( file_exists( $asset_file ) ) {
151 156 $asset = require $asset_file;
152 157
153 158 // This script serves two purposes:
@@ -154,8 +159,10 @@
154 159 // 1. It ensures all the globals that are made available to the modules are loaded.
155 160 // 2. It initializes the boot module as an inline script.
156 161 wp_register_script( 'dashboard-wp-admin-prerequisites', '', $asset['dependencies'], $asset['version'], true );
157 162
163 + $init_modules = ["@wordpress/dashboard-init"];
164 +
158 165 /*
159 166 * Add inline script to initialize the app using initSinglePage (no menuItems).
160 167 * The dynamic import is deferred until DOMContentLoaded so that all classic
161 168 * script dependencies of @wordpress/boot (wp-private-apis, wp-components,
@@ -165,12 +172,12 @@
165 172 * Chrome, evaluating before wp.theme.privateApis is defined and throwing
166 173 * "Cannot unlock an undefined object". See <https://core.trac.wordpress.org/ticket/65103>.
167 174 */
168 175 $init_js_function = <<<'JS'
169 - ( mountId, routes ) => {
176 + ( mountId, routes, initModules ) => {
170 177 const run = async () => {
171 178 const mod = await import( "@wordpress/boot" );
172 - mod.initSinglePage( { mountId, routes } );
179 + mod.initSinglePage( { mountId, routes, initModules } );
173 180 };
174 181 if ( document.readyState === "loading" ) {
175 182 document.addEventListener( "DOMContentLoaded", run );
176 183 } else {
@@ -180,12 +187,13 @@
180 187 JS;
181 188 wp_add_inline_script(
182 189 'dashboard-wp-admin-prerequisites',
183 190 sprintf(
184 - '( %s )( %s, %s );',
191 + '( %s )( %s, %s, %s );',
185 192 $init_js_function,
186 193 wp_json_encode( 'dashboard-wp-admin-app', JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),
187 - wp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )
194 + wp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),
195 + wp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )
188 196 )
189 197 );
190 198
191 199 // Register prerequisites style by filtering script dependencies to find registered styles
@@ -204,8 +212,11 @@
204 212 'id' => '@wordpress/boot',
205 213 ),
206 214 );
207 215
216 + // Add init modules as static dependencies
217 + $boot_dependencies[] = array( 'import' => 'static', 'id' => '@wordpress/dashboard-init' );
218 +
208 219 // Add all registered routes as dependencies
209 220 foreach ( $routes as $route ) {
210 221 if ( isset( $route['route_module'] ) ) {
211 222 $boot_dependencies[] = array(
@@ -262,25 +273,25 @@
262 273
263 274 #wpwrap {
264 275 overflow-y: auto;
265 276 }
266 - body {
277 + body.js {
267 278 background: #fff;
268 279 }
269 280
270 281 /* Reset wp-admin padding */
271 - #wpcontent {
282 + body.js #wpcontent {
272 283 padding-inline-start: 0;
273 284 }
274 - #wpbody-content {
285 + body.js #wpbody-content {
275 286 padding-bottom: 0;
276 287 }
277 288
278 289 /* Hide legacy admin elements */
279 - #wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {
290 + body.js #wpbody-content > div:not(#dashboard-wp-admin-app):not(#screen-meta) {
280 291 display: none;
281 292 }
282 - #wpfooter {
293 + body.js #wpfooter {
283 294 display: none;
284 295 }
285 296
286 297 /* Accessibility regions */
@@ -307,8 +318,22 @@
307 318 overflow-y: initial;
308 319 }
309 320 }
310 321 </style>
322 + <div class="wrap hide-if-js">
323 + <h1 class="wp-heading-inline"><?php echo esc_html( get_admin_page_title() ); ?></h1>
324 + <?php
325 + wp_admin_notice(
326 + __( 'This screen requires JavaScript. Enable JavaScript in your browser settings and reload the page.' ),
327 + array( 'type' => 'error' )
328 + );
329 + ?>
330 + </div>
331 + <?php
332 + // Core's pre-CSS Modules Boot layout uses this class for viewport sizing.
333 + // Remove it when the minimum supported WordPress version includes the Boot
334 + // changes from Gutenberg #81756.
335 + ?>
311 336 <div id="dashboard-wp-admin-app" class="boot-layout-container"></div>
312 337 <?php
313 338 }
314 339
@@ -313,5 +338,4 @@
313 338 }
314 339
315 340 // Hook the enqueue function to admin_enqueue_scripts
316 341 add_action( 'admin_enqueue_scripts', 'gutenberg_dashboard_wp_admin_enqueue_scripts' );
317 -