Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions features/skip-themes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,38 @@ Feature: Skipping themes
false
"""
And STDERR should be empty

@require-wp-6.1
Scenario: Skip a theme using block patterns
Given a WP installation
And I run `wp theme install blockline --activate`

When I run `wp eval 'var_dump( function_exists( "blockline_support" ) );'`
Then STDOUT should be:
"""
bool(true)
"""

When I run `wp --skip-themes=blockline eval 'var_dump( function_exists( "blockline_support" ) );'`
Then STDOUT should be:
"""
bool(false)
"""

@require-wp-6.1
Scenario: Skip a theme using block patterns with Gutenberg active
Given a WP installation
And I run `wp plugin install gutenberg --activate`
And I run `wp theme install blockline --activate`

When I run `wp eval 'var_dump( function_exists( "blockline_support" ) );'`
Then STDOUT should be:
"""
bool(true)
"""

When I run `wp --skip-themes=blockline eval 'var_dump( function_exists( "blockline_support" ) );'`
Then STDOUT should be:
"""
bool(false)
"""
13 changes: 13 additions & 0 deletions php/WP_CLI/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,19 @@ public function action_setup_theme_wp_cli_skip_themes() {
foreach ( $hooks as $hook ) {
add_filter( $hook, $wp_cli_filter_active_theme, 999 );
}

// Remove theme-related actions not directly tied into the theme lifecycle.
if ( WP_CLI::get_runner()->config['skip-themes'] ) {
$theme_related_actions = [
[ 'init', '_register_theme_block_patterns' ], // Block patterns registration in WP Core.
[ 'init', 'gutenberg_register_theme_block_patterns' ], // Block patterns registration in the GB plugin.
];
foreach ( $theme_related_actions as $action ) {
list( $hook, $callback ) = $action;
remove_action( $hook, $callback );
}
}

// Clean up after the TEMPLATEPATH and STYLESHEETPATH constants are defined
WP_CLI::add_wp_hook(
'after_setup_theme',
Expand Down