Skip to content

Commit 1bdb219

Browse files
committed
Try wp_register_block_types_from_metadata_collection function
This was added in WordPress 6.8
1 parent b7dd822 commit 1bdb219

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"author": "Greenpeace International",
66
"license": "GPL-3.0",
77
"scripts": {
8-
"start": "wp-scripts start --config webpack.config.js --mode=development",
9-
"build": "wp-scripts build --config webpack.config.js --mode=production",
8+
"start": "wp-scripts start --blocks-manifest --config webpack.config.js --mode=development",
9+
"build": "wp-scripts build --blocks-manifest --config webpack.config.js --mode=production",
1010
"analyze": "wp-scripts build --config webpack.config.js --mode=production --env analyze",
1111
"lint:css": "npx stylelint 'assets/src/scss/**/*.scss'",
1212
"lint:js": "npx eslint 'assets/src/**/*.js' 'tests/e2e/**/*.js' 'admin/js/**/*.js'",
@@ -18,7 +18,7 @@
1818
"@playwright/test": "^1.49.1",
1919
"@wordpress/e2e-test-utils-playwright": "^1.16.0",
2020
"@wordpress/eslint-plugin": "^15.1.0",
21-
"@wordpress/scripts": "^26.19.0",
21+
"@wordpress/scripts": "^31.2.0",
2222
"ajv": "^8.7.1",
2323
"autoprefixer": "^9.6.1",
2424
"babel-loader": "^8.2.3",

src/Blocks/Register.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Loader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use P4\MasterTheme\Features\Planet4Blocks;
77
use P4\MasterTheme\Patterns\BlockPattern;
88
use P4\MasterTheme\View\View;
9-
use P4\MasterTheme\Blocks\BaseBlock;
109
use RuntimeException;
1110

1211
/**
@@ -217,11 +216,12 @@ public static function add_blocks(): void
217216
new Blocks\TakeActionBoxout();//NOSONAR
218217
new Blocks\Timeline();//NOSONAR
219218
new Blocks\SecondaryNavigation();//NOSONAR
220-
Blocks\Register::registerFromAssets('TopicLink', [
221-
'render_callback' => function ($attributes) {
222-
return BaseBlock::render_frontend_from_blockname($attributes, 'planet4-blocks/topic-link');
223-
},
224-
]);
219+
220+
// Register blocks from block.json files.
221+
wp_register_block_types_from_metadata_collection(
222+
get_template_directory() . '/assets/build/blocks/',
223+
get_template_directory() . '/assets/build/blocks-manifest.php'
224+
);
225225

226226
$pattern_categories = [
227227
'page-headers' => 'Page Headers',

0 commit comments

Comments
 (0)