Skip to content

Commit e60ae18

Browse files
authored
Merge branch 'main' into try/322-refresh
2 parents 69cbb43 + 6431338 commit e60ae18

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
41+
uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

features/scaffold.feature

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Feature: WordPress code scaffolding
99
When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --theme_name=Zombieland --author=Tallahassee --author_uri=https://wp-cli.org --theme_uri=http://www.zombieland.com`
1010
Then the {THEME_DIR}/zombieland/style.css file should exist
1111
And the {THEME_DIR}/zombieland/functions.php file should exist
12+
And the {THEME_DIR}/zombieland/functions.php file should contain:
13+
"""
14+
wp_style_add_data( 'zombieland-style', 'rtl', 'add' );
15+
"""
1216
And STDOUT should be:
1317
"""
1418
Success: Created '{THEME_DIR}/zombieland'.
@@ -58,6 +62,44 @@ Feature: WordPress code scaffolding
5862
Success: Network enabled the 'Zombieland' theme.
5963
"""
6064

65+
Scenario: Scaffold a child theme and activate it with different slug and name
66+
Given a WP install
67+
68+
When I run `wp theme install twentytwentyone --force`
69+
Then STDOUT should not be empty
70+
71+
And I run `wp theme path`
72+
And save STDOUT as {THEME_DIR}
73+
74+
When I run `wp scaffold child-theme first-run --parent_theme=twentytwentyone --theme_name="First Run Name" --activate`
75+
Then STDOUT should contain:
76+
"""
77+
Success: Created '{THEME_DIR}/first-run'.
78+
"""
79+
And STDOUT should contain:
80+
"""
81+
Success: Switched to 'First Run Name' theme.
82+
"""
83+
84+
When I run `wp theme list --fields=name,status --format=csv`
85+
Then STDOUT should contain:
86+
"""
87+
first-run,active
88+
"""
89+
90+
# Now delete the theme and create it again to test the fix for the caching issue
91+
When I run `rm -rf {THEME_DIR}/first-run`
92+
And I run `wp theme activate twentytwentyone`
93+
And I run `wp scaffold child-theme first-run --parent_theme=twentytwentyone --theme_name="First Run Name" --activate`
94+
Then STDOUT should contain:
95+
"""
96+
Success: Created '{THEME_DIR}/first-run'.
97+
"""
98+
And STDOUT should contain:
99+
"""
100+
Success: Switched to 'First Run Name' theme.
101+
"""
102+
61103
Scenario: Scaffold a child theme with invalid slug
62104
Given a WP install
63105
When I try `wp scaffold child-theme . --parent_theme=simple-life`

src/Scaffold_Command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,10 @@ public function child_theme( $args, $assoc_args ) {
539539
$this->log_whether_files_written( $files_written, $skip_message, $success_message );
540540

541541
if ( Utils\get_flag_value( $assoc_args, 'activate' ) ) {
542+
wp_get_theme( $theme_slug )->cache_delete();
542543
WP_CLI::run_command( [ 'theme', 'activate', $theme_slug ] );
543544
} elseif ( Utils\get_flag_value( $assoc_args, 'enable-network' ) ) {
545+
wp_get_theme( $theme_slug )->cache_delete();
544546
WP_CLI::run_command( [ 'theme', 'enable', $theme_slug ], [ 'network' => true ] );
545547
}
546548
}

templates/child_theme_functions.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ function {{prefix_safe}}_parent_theme_enqueue_styles() {
2020
array( '{{parent_theme}}-style' ),
2121
'0.1.0'
2222
);
23+
wp_style_add_data( '{{slug}}-style', 'rtl', 'add' );
2324
}

0 commit comments

Comments
 (0)