Skip to content

Commit c23487e

Browse files
authored
Merge pull request #556 from wp-cli/feature/block-content-commands
2 parents 8c12691 + 7ad0590 commit c23487e

22 files changed

+9615
-9
lines changed

README.md

Lines changed: 965 additions & 7 deletions
Large diffs are not rendered by default.

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore:
2+
- "src/Compat/**/*"

composer.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,23 @@
120120
"post term set",
121121
"post update",
122122
"post url-to-id",
123+
"post has-blocks",
124+
"post has-block",
125+
"post block",
126+
"post block clone",
127+
"post block count",
128+
"post block export",
129+
"post block extract",
130+
"post block get",
131+
"post block import",
132+
"post block insert",
133+
"post block list",
134+
"post block move",
135+
"post block parse",
136+
"post block remove",
137+
"post block replace",
138+
"post block render",
139+
"post block update",
123140
"post-type",
124141
"post-type get",
125142
"post-type list",
@@ -220,6 +237,11 @@
220237
"classmap": [
221238
"src/"
222239
],
240+
"exclude-from-classmap": [
241+
"src/Compat/WP_HTML_Span.php",
242+
"src/Compat/WP_Block_Processor.php",
243+
"src/Compat/polyfills.php"
244+
],
223245
"files": [
224246
"entity-command.php"
225247
]
@@ -234,7 +256,6 @@
234256
"phpstan": "run-phpstan-tests",
235257
"phpunit": "run-php-unit-tests",
236258
"phpcbf": "run-phpcbf-cleanup",
237-
"phpstan": "run-phpstan-tests",
238259
"prepare-tests": "install-package-tests",
239260
"test": [
240261
"@lint",

entity-command.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
require_once $wpcli_entity_autoloader;
1212
}
1313

14+
// Load the BlockProcessorLoader class (but don't call load() yet).
15+
// The polyfills will be loaded on-demand by Block_Processor_Helper
16+
// when needed, ensuring WordPress classes take precedence if available.
17+
require_once __DIR__ . '/src/Compat/BlockProcessorLoader.php';
18+
1419
WP_CLI::add_command( 'comment', 'Comment_Command' );
1520
WP_CLI::add_command( 'comment meta', 'Comment_Meta_Command' );
1621
WP_CLI::add_command( 'menu', 'Menu_Command' );
@@ -29,6 +34,17 @@
2934
);
3035
WP_CLI::add_command( 'option', 'Option_Command' );
3136
WP_CLI::add_command( 'post', 'Post_Command' );
37+
WP_CLI::add_command(
38+
'post block',
39+
'Post_Block_Command',
40+
array(
41+
'before_invoke' => function () {
42+
if ( Utils\wp_version_compare( '5.0', '<' ) ) {
43+
WP_CLI::error( 'Requires WordPress 5.0 or greater.' );
44+
}
45+
},
46+
)
47+
);
3248
WP_CLI::add_command( 'post meta', 'Post_Meta_Command' );
3349
WP_CLI::add_command( 'post term', 'Post_Term_Command' );
3450
WP_CLI::add_command( 'post-type', 'Post_Type_Command' );

0 commit comments

Comments
 (0)