@wordpress/create-block 4.63.0 → 4.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/init-package-json.js
CHANGED
|
@@ -45,8 +45,7 @@ module.exports = async ( {
|
|
|
45
45
|
build:
|
|
46
46
|
( isDynamicVariant
|
|
47
47
|
? 'wp-scripts build --webpack-copy-php'
|
|
48
|
-
: 'wp-scripts build' ) +
|
|
49
|
-
' && wp-scripts build-blocks-manifest',
|
|
48
|
+
: 'wp-scripts build' ) + ' --blocks-manifest',
|
|
50
49
|
format: 'wp-scripts format',
|
|
51
50
|
'lint:css': 'wp-scripts lint-style',
|
|
52
51
|
'lint:js': 'wp-scripts lint-js',
|
|
@@ -55,8 +54,7 @@ module.exports = async ( {
|
|
|
55
54
|
start:
|
|
56
55
|
( isDynamicVariant
|
|
57
56
|
? 'wp-scripts start --webpack-copy-php'
|
|
58
|
-
: 'wp-scripts start' ) +
|
|
59
|
-
' && wp-scripts build-blocks-manifest',
|
|
57
|
+
: 'wp-scripts start' ) + ' --blocks-manifest',
|
|
60
58
|
} ),
|
|
61
59
|
...( wpEnv && { env: 'wp-env' } ),
|
|
62
60
|
...customScripts,
|
|
@@ -37,7 +37,17 @@
|
|
|
37
37
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
38
38
|
exit; // Exit if accessed directly.
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
{{#wpScripts}}
|
|
41
|
+
/**
|
|
42
|
+
* Registers the block using a `blocks-manifest.php` file, which improves the performance of block type registration.
|
|
43
|
+
* Behind the scenes, it also registers all assets so they can be enqueued
|
|
44
|
+
* through the block editor in the corresponding context.
|
|
45
|
+
*
|
|
46
|
+
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
|
|
47
|
+
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
|
|
48
|
+
*/
|
|
49
|
+
{{/wpScripts}}
|
|
50
|
+
{{^wpScripts}}
|
|
41
51
|
/**
|
|
42
52
|
* Registers the block using the metadata loaded from the `block.json` file.
|
|
43
53
|
* Behind the scenes, it registers also all assets so they can be enqueued
|
|
@@ -45,18 +55,38 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
|
45
55
|
*
|
|
46
56
|
* @see https://developer.wordpress.org/reference/functions/register_block_type/
|
|
47
57
|
*/
|
|
58
|
+
{{/wpScripts}}
|
|
48
59
|
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
|
|
49
60
|
{{#wpScripts}}
|
|
50
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
|
|
63
|
+
* based on the registered block metadata.
|
|
64
|
+
* Added in WordPress 6.8 to simplify the block metadata registration process added in WordPress 6.7.
|
|
65
|
+
*
|
|
66
|
+
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
|
|
67
|
+
*/
|
|
68
|
+
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
|
|
51
69
|
wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Registers the block(s) metadata from the `blocks-manifest.php` file.
|
|
75
|
+
* Added to WordPress 6.7 to improve the performance of block type registration.
|
|
76
|
+
*
|
|
77
|
+
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
|
|
78
|
+
*/
|
|
79
|
+
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
|
|
80
|
+
wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Registers the block type(s) in the `blocks-manifest.php` file.
|
|
84
|
+
*
|
|
85
|
+
* @see https://developer.wordpress.org/reference/functions/register_block_type/
|
|
86
|
+
*/
|
|
87
|
+
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
|
|
88
|
+
foreach ( array_keys( $manifest_data ) as $block_type ) {
|
|
89
|
+
register_block_type( __DIR__ . "/build/{$block_type}" );
|
|
60
90
|
}
|
|
61
91
|
{{/wpScripts}}
|
|
62
92
|
{{^wpScripts}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/create-block",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.64.1",
|
|
4
4
|
"description": "Generates PHP, JS and CSS code for registering a block for a WordPress plugin.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@inquirer/prompts": "^7.2.0",
|
|
35
|
-
"@wordpress/lazy-import": "^2.
|
|
35
|
+
"@wordpress/lazy-import": "^2.21.0",
|
|
36
36
|
"chalk": "^4.0.0",
|
|
37
37
|
"change-case": "^4.1.2",
|
|
38
38
|
"check-node-version": "^4.1.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "bbffb7567a47b4af071c0b00c1b653b3d3303809"
|
|
52
52
|
}
|