diff --git a/bin/build-plugin-zip.sh b/bin/build-plugin-zip.sh index 15eabca56530be..5479467bcd8a98 100755 --- a/bin/build-plugin-zip.sh +++ b/bin/build-plugin-zip.sh @@ -109,7 +109,7 @@ npm run build php bin/generate-gutenberg-php.php > gutenberg.tmp.php mv gutenberg.tmp.php gutenberg.php -build_files=$(ls build/*/*.{js,css,asset.php} build/block-library/blocks/*.{php,json}) +build_files=$(ls build/*/*.{js,css,asset.php} build/block-library/blocks/*/*.{php,json}) # Generate the plugin zip file. status "Creating archive... 🎁" diff --git a/lib/blocks.php b/lib/blocks.php index e0aa1725f6725f..9a7a74180d48ed 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -39,31 +39,31 @@ function gutenberg_reregister_core_block_types() { } $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', - 'navigation.php' => 'core/navigation', - 'rss.php' => 'core/rss', - 'shortcode.php' => 'core/shortcode', - 'search.php' => 'core/search', - 'social-link.php' => gutenberg_get_registered_social_link_blocks(), - 'tag-cloud.php' => 'core/tag-cloud', - 'site-title.php' => 'core/site-title', - 'template-part.php' => 'core/template-part', - 'post-title.php' => 'core/post-title', - 'post-content.php' => 'core/post-content', - 'post-author.php' => 'core/post-author', - 'post-date.php' => 'core/post-date', - 'post-excerpt.php' => 'core/post-excerpt', + 'archives' => 'core/archives', + 'block' => 'core/block', + 'calendar' => 'core/calendar', + 'categories' => 'core/categories', + 'latest-comments' => 'core/latest-comments', + 'latest-posts' => 'core/latest-posts', + 'legacy-widget' => 'core/legacy-widget', + 'navigation' => 'core/navigation', + 'rss' => 'core/rss', + 'shortcode' => 'core/shortcode', + 'search' => 'core/search', + 'social-link' => gutenberg_get_registered_social_link_blocks(), + 'tag-cloud' => 'core/tag-cloud', + 'site-title' => 'core/site-title', + 'template-part' => 'core/template-part', + 'post-title' => 'core/post-title', + 'post-content' => 'core/post-content', + 'post-author' => 'core/post-author', + 'post-date' => 'core/post-date', + 'post-excerpt' => 'core/post-excerpt', ); $registry = WP_Block_Type_Registry::get_instance(); - foreach ( $block_names as $file => $block_names ) { + foreach ( $block_names as $folder_name => $block_names ) { if ( ! file_exists( $blocks_dir . $file ) ) { return; } @@ -80,7 +80,7 @@ function gutenberg_reregister_core_block_types() { } } - require $blocks_dir . $file; + require $blocks_dir . $folder_name . '/index.php'; } } add_action( 'init', 'gutenberg_reregister_core_block_types' ); diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index ce227a16df5622..2329011299c7e3 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -21,7 +21,7 @@ function render_block_core_shortcode( $attributes, $content ) { * Registers the `core/shortcode` block on server. */ function register_block_core_shortcode() { - $path = __DIR__ . '/shortcode.json'; + $path = realpath( __DIR__ . '/block.json' ); $metadata = json_decode( file_get_contents( $path ), true ); register_block_type( 'core/shortcode', diff --git a/webpack.config.js b/webpack.config.js index 0f7f5bb91039a8..0fc198587b02a3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -119,7 +119,7 @@ module.exports = { { from: './packages/block-library/src/**/index.php', test: new RegExp( `([\\w-]+)${ escapeRegExp( sep ) }index\\.php$` ), - to: 'build/block-library/blocks/[1].php', + to: 'build/block-library/blocks/[1]/index.php', transform( content ) { content = content.toString(); @@ -149,12 +149,10 @@ module.exports = { .replace( /(add_action\(\s*'init',\s*'gutenberg_register_block_[^']+'(?!,))/, '$1, 20' ); }, }, - ] ), - new CopyWebpackPlugin( [ { - from: './packages/block-library/src/+(shortcode)/block.json', + from: './packages/block-library/src/*/block.json', test: new RegExp( `([\\w-]+)${ escapeRegExp( sep ) }block\\.json$` ), - to: 'build/block-library/blocks/[1].json', + to: 'build/block-library/blocks/[1]/block.json', }, ] ), new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ),