Skip to content

Commit a2addd6

Browse files
youknowriaddmsnell
authored andcommitted
Build: Improve Gutenberg integration workflow.
This changeset improves the Gutenberg build integration to simplify the developer workflow and reinstore a flow similar to how package dependencies worked before the Gutenberg checkout-and-build approach was introduced. Key improvements: * Automatic rebuild on ref change: Adds a new `gutenberg:sync` script that stores a hash of the built ref in `.gutenberg-hash` and only rebuilds when the ref changes. * Full integration on `npm install`: Running `npm install` now produces a fully working development environment with Gutenberg assets in `src/`. * Clean Gutenberg checkout: Restores Gutenberg's `package.json` after the build completes. * Stops copying `.js.map` files to `wp-includes/js/dist` since they reference non-existent paths. * Remove package.json files from the build folder. * Avoid closures and use prefixed functions. * Updates build checks to use `jquery.js` instead of `edit-post.js` as the build indicator. Props youknowriad, ellatrix, mcsf, dmsnell, ntsekouras, jorgefilipecosta, tobiasbg, peterwilsoncc. Fixes #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@61492 602fd350-edb4-49c9-b593-d223f7449a82 (cherry picked from commit e626725)
1 parent d4a85b7 commit a2addd6

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/wp-includes/blocks.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,10 @@ function parse_blocks( $content ) {
24212421
*/
24222422
$parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' );
24232423

2424+
if ( ! class_exists( $parser_class ) ) {
2425+
return array();
2426+
}
2427+
24242428
$parser = new $parser_class();
24252429
return $parser->parse( $content );
24262430
}

src/wp-includes/formatting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5227,6 +5227,11 @@ function wp_pre_kses_less_than_callback( $matches ) {
52275227
* @return string Filtered text to run through KSES.
52285228
*/
52295229
function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) {
5230+
// If the block parser isn't available, skip block attribute filtering.
5231+
if ( ! class_exists( 'WP_Block_Parser' ) ) {
5232+
return $content;
5233+
}
5234+
52305235
/*
52315236
* `filter_block_content` is expected to call `wp_kses`. Temporarily remove
52325237
* the filter to avoid recursion.

src/wp-settings.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,15 @@
377377
require ABSPATH . WPINC . '/class-wp-block.php';
378378
require ABSPATH . WPINC . '/class-wp-block-list.php';
379379
require ABSPATH . WPINC . '/class-wp-block-metadata-registry.php';
380-
require ABSPATH . WPINC . '/class-wp-block-parser-block.php';
381-
require ABSPATH . WPINC . '/class-wp-block-parser-frame.php';
382-
require ABSPATH . WPINC . '/class-wp-block-parser.php';
380+
if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser-block.php' ) ) {
381+
require ABSPATH . WPINC . '/class-wp-block-parser-block.php';
382+
}
383+
if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser-frame.php' ) ) {
384+
require ABSPATH . WPINC . '/class-wp-block-parser-frame.php';
385+
}
386+
if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser.php' ) ) {
387+
require ABSPATH . WPINC . '/class-wp-block-parser.php';
388+
}
383389
require ABSPATH . WPINC . '/class-wp-classic-to-block-menu-converter.php';
384390
require ABSPATH . WPINC . '/class-wp-navigation-fallback.php';
385391
require ABSPATH . WPINC . '/block-bindings.php';

0 commit comments

Comments
 (0)