PluginProbe
Gutenberg / 24.0.0
Gutenberg v24.0.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 12.6.0 All 403 releases
← All changes | lib/client-assets.php +50 -24 23.0.124.0.0 View file →
@@ -25,11 +25,11 @@
25 25 * Retrieves a URL to a file in the gutenberg plugin.
26 26 *
27 27 * @since 0.1.0
28 28 *
29 - * @param string $path Relative path of the desired file.
29 + * @param string $path Relative path of the desired file.
30 30 *
31 - * @return string Fully qualified URL pointing to the desired file.
31 + * @return string Fully qualified URL pointing to the desired file.
32 32 */
33 33 function gutenberg_url( $path ) {
34 34 return plugins_url( $path, __DIR__ );
35 35 }
@@ -86,26 +86,17 @@
86 86 }
87 87 add_filter( 'load_script_translation_file', 'gutenberg_override_translation_file', 10, 2 );
88 88
89 89 /**
90 - * Handle special case dependencies for wp-block-library that depend on runtime conditions.
90 + * Adds the 'editor' dependency to wp-block-library, required by the Classic block.
91 91 *
92 - * This adds the 'editor' dependency conditionally based on experiments and classic block requirements.
93 - * All other script registrations are handled by the auto-generated build/scripts.php file.
94 - *
95 92 * @param WP_Scripts $scripts WP_Scripts instance.
96 93 */
97 94 function gutenberg_register_block_library_script_special_case( $scripts ) {
98 95 $handle = 'wp-block-library';
99 96 $script = $scripts->query( $handle, 'registered' );
100 - if (
101 - ! gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ||
102 - ! empty( $_GET['requiresTinymce'] ) ||
103 - gutenberg_post_being_edited_requires_classic_block()
104 - ) {
105 - if ( ! in_array( 'editor', $script->deps, true ) ) {
106 - $script->deps[] = 'editor';
107 - }
97 + if ( ! in_array( 'editor', $script->deps, true ) ) {
98 + $script->deps[] = 'editor';
108 99 }
109 100 }
110 101 add_action( 'wp_default_scripts', 'gutenberg_register_block_library_script_special_case', 11 );
111 102
@@ -133,10 +124,12 @@
133 124 // else (for development or test) default to use the current time.
134 125 $version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();
135 126 $suffix = SCRIPT_DEBUG ? '' : '.min';
136 127
137 - // wp-components: add dashicons (icon font dependency)
138 - $styles->query( 'wp-components', 'registered' )->deps[] = 'dashicons';
128 + // wp-components: add dashicons (icon font dependency) and design tokens.
129 + $components_style = $styles->query( 'wp-components', 'registered' );
130 + $components_style->deps[] = 'dashicons';
131 + $components_style->deps[] = 'wp-theme';
139 132
140 133 // wp-edit-post: add wp-edit-blocks (custom handle not auto-inferred)
141 134 $styles->query( 'wp-edit-post', 'registered' )->deps[] = 'wp-edit-blocks';
142 135
@@ -151,8 +144,19 @@
151 144
152 145 // wp-customize-widgets: add wp-edit-blocks (custom handle not auto-inferred)
153 146 $styles->query( 'wp-customize-widgets', 'registered' )->deps[] = 'wp-edit-blocks';
154 147
148 + gutenberg_override_style(
149 + $styles,
150 + 'wp-theme',
151 + gutenberg_url( 'build/styles/theme/design-tokens' . $suffix . '.css' ),
152 + array(),
153 + $version
154 + );
155 + $styles->add_data( 'wp-theme', 'rtl', 'replace' );
156 + $styles->add_data( 'wp-theme', 'suffix', $suffix );
157 + $styles->add_data( 'wp-theme', 'path', gutenberg_dir_path() . 'build/styles/theme/design-tokens' . $suffix . '.css' );
158 +
155 159 // Register wp-base-styles and add it to the already registered wp-admin stylesheet
156 160 gutenberg_override_style(
157 161 $styles,
158 162 'wp-base-styles',
@@ -188,8 +192,12 @@
188 192 $styles->add_data( 'wp-block-library', 'path', gutenberg_dir_path() . 'build/styles/block-library/' . $block_library_filename . $suffix . '.css' );
189 193
190 194 // Only add CONTENT styles here that should be enqueued in the iframe!
191 195 $wp_edit_blocks_dependencies = array(
196 + // Design System tokens load first so the `:root` CSS custom
197 + // properties are defined before any consuming stylesheet reads
198 + // them inside the editor iframe.
199 + 'wp-theme',
192 200 'wp-components',
193 201 // This need to be added before the block library styles,
194 202 // The block library styles override the "reset" styles.
195 203 'wp-reset-editor-styles',
@@ -369,12 +377,17 @@
369 377 function gutenberg_register_vendor_scripts( $scripts ) {
370 378 $extension = SCRIPT_DEBUG ? '.js' : '.min.js';
371 379 $vendors_dir = gutenberg_dir_path() . 'build/scripts/vendors/';
372 380
381 + // When the React 19 experiment is enabled, register React 19 vendor
382 + // scripts under the `react`, `react-dom`, and `react-jsx-runtime` handles.
383 + $use_react_19 = gutenberg_is_experiment_enabled( 'gutenberg-react-19' );
384 +
373 385 $vendor_handles = array( 'react', 'react-dom', 'react-jsx-runtime' );
374 386
375 387 foreach ( $vendor_handles as $handle ) {
376 - $asset_file = $vendors_dir . $handle . '.min.asset.php';
388 + $source = $use_react_19 ? $handle . '-19' : $handle;
389 + $asset_file = $vendors_dir . $source . '.min.asset.php';
377 390 $asset = file_exists( $asset_file ) ? require $asset_file : array();
378 391 $dependencies = $asset['dependencies'] ?? array();
379 392 $version = $asset['version'] ?? '0';
380 393
@@ -380,9 +393,9 @@
380 393
381 394 gutenberg_override_script(
382 395 $scripts,
383 396 $handle,
384 - gutenberg_url( 'build/scripts/vendors/' . $handle . $extension ),
397 + gutenberg_url( 'build/scripts/vendors/' . $source . $extension ),
385 398 $dependencies,
386 399 $version
387 400 );
388 401 }
@@ -435,8 +448,11 @@
435 448 // Enqueue stored styles.
436 449 add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_stored_styles' );
437 450 add_action( 'wp_footer', 'gutenberg_enqueue_stored_styles', 1 );
438 451
452 +/**
453 + * Enqueues the LaTeX to MathML loader script module in the block editor.
454 + */
439 455 add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_latex_to_mathml_loader' );
440 456 function gutenberg_enqueue_latex_to_mathml_loader() {
441 457 wp_enqueue_script_module( '@wordpress/latex-to-mathml/loader' );
442 458 }
@@ -449,15 +465,25 @@
449 465 * when client-side media processing is triggered via @wordpress/upload-media.
450 466 *
451 467 * @see packages/vips/src/loader.ts
452 468 */
453 -if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
454 - add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_vips_loader' );
455 -}
469 +add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_vips_loader' );
456 470 function gutenberg_enqueue_vips_loader() {
457 471 wp_enqueue_script_module( '@wordpress/vips/loader' );
458 472 }
459 473
460 -add_action( 'admin_enqueue_scripts', 'gutenberg_enqueue_core_abilities' );
461 -function gutenberg_enqueue_core_abilities() {
462 - wp_enqueue_script_module( '@wordpress/core-abilities' );
474 +/**
475 + * Enqueue the video-conversion loader script module in the block editor.
476 + *
477 + * This registers @wordpress/video-conversion/worker as a dynamic dependency
478 + * in the import map, enabling on-demand loading of the WebCodecs-based
479 + * GIF-to-video processing module when animated GIF conversion is triggered
480 + * via @wordpress/upload-media.
481 + *
482 + * @see packages/video-conversion/src/loader.ts
483 + */
484 +if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
485 + add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_video_conversion_loader' );
486 +}
487 +function gutenberg_enqueue_video_conversion_loader() {
488 + wp_enqueue_script_module( '@wordpress/video-conversion/loader' );
463 489 }