From 002de59f3df1d8c54695863d9bd8c113dc8a91d0 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Sun, 27 Jan 2019 16:43:17 -0500 Subject: [PATCH 1/9] Build Tools: Exclude build files from PHPCS --- phpcs.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e328ac8dde3fc1..6b1456e982e296 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -33,6 +33,7 @@ ./packages/block-serialization-spec-parser/parser.php + ./build lib/class-wp-rest-block-renderer-controller.php From 9ba6e2b02b1ce9374884c2195765ee257e00cce1 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 25 Jan 2019 23:02:51 -0500 Subject: [PATCH 2/9] Blocks: Re-register core blocks via build copy prefixing --- lib/load.php | 78 +++++++++---------- packages/block-library/src/archives/index.php | 1 - packages/block-library/src/block/index.php | 26 ++++--- .../block-library/src/categories/index.php | 1 - .../src/latest-comments/index.php | 77 ++++++++++-------- .../block-library/src/latest-posts/index.php | 1 - packages/block-library/src/rss/index.php | 1 - packages/block-library/src/search/index.php | 1 - .../block-library/src/shortcode/index.php | 1 - .../block-library/src/tag-cloud/index.php | 1 - webpack.config.js | 30 ++++++- 11 files changed, 126 insertions(+), 92 deletions(-) diff --git a/lib/load.php b/lib/load.php index f469513fd83a91..b124585e045ba9 100644 --- a/lib/load.php +++ b/lib/load.php @@ -30,49 +30,45 @@ require dirname( __FILE__ ) . '/widgets.php'; require dirname( __FILE__ ) . '/widgets-page.php'; -// Register server-side code for individual blocks. -if ( ! function_exists( 'render_block_core_archives' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/archives/index.php'; -} -if ( ! function_exists( 'render_block_core_block' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/block/index.php'; -} -if ( ! function_exists( 'render_block_core_categories' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/categories/index.php'; -} -// Currently merged in core as `gutenberg_render_block_core_latest_comments`, -// expected to change soon. -if ( ! function_exists( 'render_block_core_calendar' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/calendar/index.php'; -} -if ( ! function_exists( 'render_block_core_latest_comments' ) - && ! function_exists( 'gutenberg_render_block_core_latest_comments' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/latest-comments/index.php'; -} -if ( ! function_exists( 'render_block_core_latest_posts' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/latest-posts/index.php'; -} - - /** - * Start: Include for phase 2 - */ -if ( ! function_exists( 'render_block_legacy_widget' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/legacy-widget/index.php'; -} -/** - * End: Include for phase 2 + * Unregisters the core set of blocks. This should occur on the default + * priority, immediately prior to Gutenberg's own action binding. */ +function gutenberg_unregister_core_block_types() { + $registry = WP_Block_Type_Registry::get_instance(); + $block_names = array( + 'core/archives', + 'core/block', + 'core/calendar', + 'core/categories', + 'core/latest-comments', + 'core/latest-posts', + 'core/legacy-widget', + 'core/rss', + 'core/shortcode', + 'core/search', + 'core/tag-cloud', + ); -if ( ! function_exists( 'render_block_core_rss' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/rss/index.php'; -} -if ( ! function_exists( 'render_block_core_shortcode' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/shortcode/index.php'; -} -if ( ! function_exists( 'render_block_core_tag_cloud' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/tag-cloud/index.php'; + foreach ( $block_names as $block_name ) { + if ( $registry->is_registered( $block_name ) ) { + $registry->unregister( $block_name ); + } + } } -if ( ! function_exists( 'render_block_core_search' ) ) { - require dirname( __FILE__ ) . '/../packages/block-library/src/search/index.php'; + +if ( file_exists( dirname( __FILE__ ) . '/../build/block-library/blocks' ) ) { + add_action( 'init', 'gutenberg_unregister_core_block_types' ); + + require dirname( __FILE__ ) . '/../build/block-library/blocks/archives.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/block.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/calendar.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/categories.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/latest-comments.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/latest-posts.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/legacy-widget.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/rss.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/shortcode.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/search.php'; + require dirname( __FILE__ ) . '/../build/block-library/blocks/tag-cloud.php'; } diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 3d7b5b42f4ae43..435f7b7536f367 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -143,5 +143,4 @@ function register_block_core_archives() { ) ); } - add_action( 'init', 'register_block_core_archives' ); diff --git a/packages/block-library/src/block/index.php b/packages/block-library/src/block/index.php index aa235f170333ee..2f68a3750d154a 100644 --- a/packages/block-library/src/block/index.php +++ b/packages/block-library/src/block/index.php @@ -29,15 +29,21 @@ function render_block_core_block( $attributes ) { return do_blocks( $reusable_block->post_content ); } -register_block_type( - 'core/block', - array( - 'attributes' => array( - 'ref' => array( - 'type' => 'number', +/** + * Registers the `core/block` block. + */ +function register_block_core_block() { + register_block_type( + 'core/block', + array( + 'attributes' => array( + 'ref' => array( + 'type' => 'number', + ), ), - ), - 'render_callback' => 'render_block_core_block', - ) -); + 'render_callback' => 'render_block_core_block', + ) + ); +} +add_action( 'init', 'register_block_core_block' ); diff --git a/packages/block-library/src/categories/index.php b/packages/block-library/src/categories/index.php index 57042046061d26..a995e447e28c35 100644 --- a/packages/block-library/src/categories/index.php +++ b/packages/block-library/src/categories/index.php @@ -98,5 +98,4 @@ function register_block_core_categories() { ) ); } - add_action( 'init', 'register_block_core_categories' ); diff --git a/packages/block-library/src/latest-comments/index.php b/packages/block-library/src/latest-comments/index.php index ae14d31b6f1c50..195f536ae9197c 100644 --- a/packages/block-library/src/latest-comments/index.php +++ b/packages/block-library/src/latest-comments/index.php @@ -150,36 +150,49 @@ function render_block_core_latest_comments( $attributes = array() ) { return $block_content; } -register_block_type( - 'core/latest-comments', - array( - 'attributes' => array( - 'align' => array( - 'type' => 'string', - 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), - ), - 'className' => array( - 'type' => 'string', - ), - 'commentsToShow' => array( - 'type' => 'number', - 'default' => 5, - 'minimum' => 1, - 'maximum' => 100, - ), - 'displayAvatar' => array( - 'type' => 'boolean', - 'default' => true, - ), - 'displayDate' => array( - 'type' => 'boolean', - 'default' => true, - ), - 'displayExcerpt' => array( - 'type' => 'boolean', - 'default' => true, +/** + * Registers the `core/latest-comments` block. + */ +function register_block_core_latest_comments() { + register_block_type( + 'core/latest-comments', + array( + 'attributes' => array( + 'align' => array( + 'type' => 'string', + 'enum' => array( + 'left', + 'center', + 'right', + 'wide', + 'full' + ), + ), + 'className' => array( + 'type' => 'string', + ), + 'commentsToShow' => array( + 'type' => 'number', + 'default' => 5, + 'minimum' => 1, + 'maximum' => 100, + ), + 'displayAvatar' => array( + 'type' => 'boolean', + 'default' => true, + ), + 'displayDate' => array( + 'type' => 'boolean', + 'default' => true, + ), + 'displayExcerpt' => array( + 'type' => 'boolean', + 'default' => true, + ), ), - ), - 'render_callback' => 'render_block_core_latest_comments', - ) -); + 'render_callback' => 'render_block_core_latest_comments', + ) + ); +} + +add_action( 'init', 'register_block_core_latest_comments' ); diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 888f99c8879924..070a70cd1860d4 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -127,5 +127,4 @@ function register_block_core_latest_posts() { ) ); } - add_action( 'init', 'register_block_core_latest_posts' ); diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index b5fe3abaf563be..65a77d91823609 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -133,5 +133,4 @@ function register_block_core_rss() { ) ); } - add_action( 'init', 'register_block_core_rss' ); diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index ac7da463e92f2e..3f344da4781a0d 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -78,5 +78,4 @@ function register_block_core_search() { ) ); } - add_action( 'init', 'register_block_core_search' ); diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index 1c0761250d2cfd..c3bb4c9449b08c 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -28,5 +28,4 @@ function register_block_core_shortcode() { ) ); } - add_action( 'init', 'register_block_core_shortcode' ); diff --git a/packages/block-library/src/tag-cloud/index.php b/packages/block-library/src/tag-cloud/index.php index c60f8a1dd6f541..46cd0e66062201 100644 --- a/packages/block-library/src/tag-cloud/index.php +++ b/packages/block-library/src/tag-cloud/index.php @@ -67,5 +67,4 @@ function register_block_core_tag_cloud() { ) ); } - add_action( 'init', 'register_block_core_tag_cloud' ); diff --git a/webpack.config.js b/webpack.config.js index dba1661ec492f5..a0fc643355ea22 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,8 +5,8 @@ const { DefinePlugin } = require( 'webpack' ); const WebpackRTLPlugin = require( 'webpack-rtl-plugin' ); const CopyWebpackPlugin = require( 'copy-webpack-plugin' ); const postcss = require( 'postcss' ); -const { get } = require( 'lodash' ); -const { basename } = require( 'path' ); +const { get, escapeRegExp } = require( 'lodash' ); +const { basename, sep } = require( 'path' ); /** * WordPress dependencies @@ -105,5 +105,31 @@ module.exports = { }, } ) ) ), + new CopyWebpackPlugin( [ + { + from: './packages/block-library/src/**/index.php', + test: new RegExp( `([\\w-]+)${ escapeRegExp( sep ) }index\\.php$` ), + to: 'build/block-library/blocks/[1].php', + transform( content ) { + content = content.toString(); + + // Within content, search for any function definitions. For + // each, replace every other reference to it in the file. + return content + .match( /^function [^\(]+/gm ) + .reduce( ( result, functionName ) => { + // Trim leading "function " prefix from match. + functionName = functionName.slice( 9 ); + + // Prepend the Gutenberg prefix, substituting any + // other core prefix (e.g. "wp_"). + return result.replace( + new RegExp( functionName, 'g' ), + ( match ) => 'gutenberg_' + match.replace( /^wp_/, '' ) + ); + }, content ); + }, + }, + ] ), ], }; From 7138e38bb63731dcc7107957fda24299d3ee5150 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 8 Feb 2019 15:54:21 -0500 Subject: [PATCH 3/9] Blocks: Discover block overrides from built artifact --- lib/load.php | 55 +++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/lib/load.php b/lib/load.php index b124585e045ba9..959a918d76e8f6 100644 --- a/lib/load.php +++ b/lib/load.php @@ -31,44 +31,29 @@ require dirname( __FILE__ ) . '/widgets-page.php'; /** - * Unregisters the core set of blocks. This should occur on the default - * priority, immediately prior to Gutenberg's own action binding. + * Discovers block files from the plugin built artifact, unregistering the + * equivalent in core if already defined, then includes the block file. */ -function gutenberg_unregister_core_block_types() { - $registry = WP_Block_Type_Registry::get_instance(); - $block_names = array( - 'core/archives', - 'core/block', - 'core/calendar', - 'core/categories', - 'core/latest-comments', - 'core/latest-posts', - 'core/legacy-widget', - 'core/rss', - 'core/shortcode', - 'core/search', - 'core/tag-cloud', - ); - - foreach ( $block_names as $block_name ) { +function gutenberg_reregister_core_block_types() { + // Blocks directory may not exist if working from a fresh clone. + $blocks_dir = dirname( __FILE__ ) . '/../build/block-library/blocks/'; + if ( ! file_exists( $blocks_dir ) ) { + return; + } + $registry = WP_Block_Type_Registry::get_instance(); + $files = scandir( $blocks_dir ); + foreach ( $files as $file ) { + $parts = pathinfo( $file ); + // Ignore all non-PHP files, subdirectories, path traversal. + if ( 'php' !== $parts['extension'] ) { + continue; + } + // Derive the assumed block name by file path. + $block_name = 'core/' . $parts['filename']; if ( $registry->is_registered( $block_name ) ) { $registry->unregister( $block_name ); } + require $blocks_dir . $file; } } - -if ( file_exists( dirname( __FILE__ ) . '/../build/block-library/blocks' ) ) { - add_action( 'init', 'gutenberg_unregister_core_block_types' ); - - require dirname( __FILE__ ) . '/../build/block-library/blocks/archives.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/block.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/calendar.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/categories.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/latest-comments.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/latest-posts.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/legacy-widget.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/rss.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/shortcode.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/search.php'; - require dirname( __FILE__ ) . '/../build/block-library/blocks/tag-cloud.php'; -} +add_action( 'init', 'gutenberg_reregister_core_block_types' ); From 3dbbbe53a71b3484e834d6e4c47fecafaec103d7 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Mar 2019 16:54:29 -0500 Subject: [PATCH 4/9] Blocks: Reimplement block reregistering as hard-coded list --- lib/load.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/load.php b/lib/load.php index 959a918d76e8f6..329f11efb59369 100644 --- a/lib/load.php +++ b/lib/load.php @@ -31,8 +31,8 @@ require dirname( __FILE__ ) . '/widgets-page.php'; /** - * Discovers block files from the plugin built artifact, unregistering the - * equivalent in core if already defined, then includes the block file. + * Substitutes the implementation of a core-registered block type, if exists, + * with the built result from the plugin. */ function gutenberg_reregister_core_block_types() { // Blocks directory may not exist if working from a fresh clone. @@ -40,16 +40,24 @@ function gutenberg_reregister_core_block_types() { if ( ! file_exists( $blocks_dir ) ) { return; } + $block_names = array( + 'archives.php' => 'core/archives', + 'block.php' => 'core/block', + 'calendar.php' => 'core/calendar', + 'categories.php' => 'core/categories', + 'latest-comments.php' => 'core/latest-comments', + 'latest-posts.php' => 'core/latest-posts', + 'legacy-widget.php' => 'core/legacy-widget', + 'rss.php' => 'core/rss', + 'shortcode.php' => 'core/shortcode', + 'search.php' => 'core/search', + 'tag-cloud.php' => 'core/tag-cloud', + ); $registry = WP_Block_Type_Registry::get_instance(); - $files = scandir( $blocks_dir ); - foreach ( $files as $file ) { - $parts = pathinfo( $file ); - // Ignore all non-PHP files, subdirectories, path traversal. - if ( 'php' !== $parts['extension'] ) { - continue; + foreach ( $block_names as $file => $block_name ) { + if ( ! file_exists( $blocks_dir . $file ) ) { + return; } - // Derive the assumed block name by file path. - $block_name = 'core/' . $parts['filename']; if ( $registry->is_registered( $block_name ) ) { $registry->unregister( $block_name ); } @@ -57,3 +65,4 @@ function gutenberg_reregister_core_block_types() { } } add_action( 'init', 'gutenberg_reregister_core_block_types' ); + From ea85dcf40fae163e47708a9c5fff59041d047d81 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Mar 2019 17:11:37 -0500 Subject: [PATCH 5/9] Blocks: Modify priority for blocks registration during build --- webpack.config.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index a0fc643355ea22..ce371dcb9e9825 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -127,7 +127,16 @@ module.exports = { new RegExp( functionName, 'g' ), ( match ) => 'gutenberg_' + match.replace( /^wp_/, '' ) ); - }, content ); + }, content ) + // The core blocks override procedure takes place in + // the init action default priority to ensure that core + // blocks would have been registered already. Since the + // blocks implementations occur at the default priority + // and due to WordPress hooks behavior not considering + // mutations to the same priority during another's + // callback, the Gutenberg build blocks are modified + // to occur at a later priority. + .replace( /(add_action\(\s*'init',\s*'register_block_[^']+'(?!,))/, '$1, 20' ); }, }, ] ), From 5bad3511fa132785389f6a66e3deb08180b661e5 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 5 Mar 2019 17:14:26 -0500 Subject: [PATCH 6/9] Blocks: Move blocks reregister function to standalone file --- lib/blocks.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ lib/load.php | 38 +------------------------------------- 2 files changed, 48 insertions(+), 37 deletions(-) create mode 100644 lib/blocks.php diff --git a/lib/blocks.php b/lib/blocks.php new file mode 100644 index 00000000000000..fc3adb8a09efa3 --- /dev/null +++ b/lib/blocks.php @@ -0,0 +1,47 @@ + 'core/archives', + 'block.php' => 'core/block', + 'calendar.php' => 'core/calendar', + 'categories.php' => 'core/categories', + 'latest-comments.php' => 'core/latest-comments', + 'latest-posts.php' => 'core/latest-posts', + 'legacy-widget.php' => 'core/legacy-widget', + 'rss.php' => 'core/rss', + 'shortcode.php' => 'core/shortcode', + 'search.php' => 'core/search', + 'tag-cloud.php' => 'core/tag-cloud', + ); + + $registry = WP_Block_Type_Registry::get_instance(); + + foreach ( $block_names as $file => $block_name ) { + if ( ! file_exists( $blocks_dir . $file ) ) { + return; + } + + if ( $registry->is_registered( $block_name ) ) { + $registry->unregister( $block_name ); + } + + require $blocks_dir . $file; + } +} +add_action( 'init', 'gutenberg_reregister_core_block_types' ); diff --git a/lib/load.php b/lib/load.php index 329f11efb59369..4010f805cad521 100644 --- a/lib/load.php +++ b/lib/load.php @@ -24,45 +24,9 @@ require dirname( __FILE__ ) . '/rest-api.php'; } +require dirname( __FILE__ ) . '/blocks.php'; require dirname( __FILE__ ) . '/client-assets.php'; require dirname( __FILE__ ) . '/i18n.php'; require dirname( __FILE__ ) . '/demo.php'; require dirname( __FILE__ ) . '/widgets.php'; require dirname( __FILE__ ) . '/widgets-page.php'; - -/** - * Substitutes the implementation of a core-registered block type, if exists, - * with the built result from the plugin. - */ -function gutenberg_reregister_core_block_types() { - // Blocks directory may not exist if working from a fresh clone. - $blocks_dir = dirname( __FILE__ ) . '/../build/block-library/blocks/'; - if ( ! file_exists( $blocks_dir ) ) { - return; - } - $block_names = array( - 'archives.php' => 'core/archives', - 'block.php' => 'core/block', - 'calendar.php' => 'core/calendar', - 'categories.php' => 'core/categories', - 'latest-comments.php' => 'core/latest-comments', - 'latest-posts.php' => 'core/latest-posts', - 'legacy-widget.php' => 'core/legacy-widget', - 'rss.php' => 'core/rss', - 'shortcode.php' => 'core/shortcode', - 'search.php' => 'core/search', - 'tag-cloud.php' => 'core/tag-cloud', - ); - $registry = WP_Block_Type_Registry::get_instance(); - foreach ( $block_names as $file => $block_name ) { - if ( ! file_exists( $blocks_dir . $file ) ) { - return; - } - if ( $registry->is_registered( $block_name ) ) { - $registry->unregister( $block_name ); - } - require $blocks_dir . $file; - } -} -add_action( 'init', 'gutenberg_reregister_core_block_types' ); - From 9aa0c8242d3cabc27fd8e589e2c6325fdd498d32 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 19 Mar 2019 09:40:56 -0400 Subject: [PATCH 7/9] Comma comma comma comma comma chameleon --- packages/block-library/src/latest-comments/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/latest-comments/index.php b/packages/block-library/src/latest-comments/index.php index 195f536ae9197c..504815bf8cbecc 100644 --- a/packages/block-library/src/latest-comments/index.php +++ b/packages/block-library/src/latest-comments/index.php @@ -165,7 +165,7 @@ function register_block_core_latest_comments() { 'center', 'right', 'wide', - 'full' + 'full', ), ), 'className' => array( From 761bf1eb25cd553a0cbc49451974bb630a865551 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 19 Mar 2019 15:15:56 +0100 Subject: [PATCH 8/9] Update regex in webpack config to contain gutenberg as well --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index ce371dcb9e9825..a8b11fd9aac6f9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -136,7 +136,7 @@ module.exports = { // mutations to the same priority during another's // callback, the Gutenberg build blocks are modified // to occur at a later priority. - .replace( /(add_action\(\s*'init',\s*'register_block_[^']+'(?!,))/, '$1, 20' ); + .replace( /(add_action\(\s*'init',\s*'gutenberg_register_block_[^']+'(?!,))/, '$1, 20' ); }, }, ] ), From 38537a6e98467a194a64bf87165728ddbef6b0b8 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 25 Mar 2019 14:41:38 +0100 Subject: [PATCH 9/9] Update build plugin zip script to include block PHP files from the new location --- bin/build-plugin-zip.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/build-plugin-zip.sh b/bin/build-plugin-zip.sh index 6c6d9d10512eee..a518e83b0e3119 100755 --- a/bin/build-plugin-zip.sh +++ b/bin/build-plugin-zip.sh @@ -107,14 +107,13 @@ npm run build php bin/generate-gutenberg-php.php > gutenberg.tmp.php mv gutenberg.tmp.php gutenberg.php -build_files=$(ls build/*/*.{js,css}) +build_files=$(ls build/*/*.{js,css} build/block-library/blocks/*.php) # Generate the plugin zip file. status "Creating archive... 🎁" zip -r gutenberg.zip \ gutenberg.php \ lib/*.php \ - packages/block-library/src/*/*.php \ packages/block-serialization-default-parser/*.php \ post-content.php \ $vendor_scripts \