From ab774e674d4f4d8a43639e657eb5d5516d6d903f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:38:16 +0000 Subject: [PATCH 1/4] Initial plan From 965b778718e918c9cee7eafcde600b29e8700090 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:42:25 +0000 Subject: [PATCH 2/4] Fix child-theme error when --path argument contains relative segments (..) Agent-Logs-Url: https://github.com/wp-cli/scaffold-command/sessions/07147131-58ed-4421-a27b-7fd97a13f800 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/scaffold.feature | 10 ++++++++++ src/Scaffold_Command.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/features/scaffold.feature b/features/scaffold.feature index 652dc5d9..5dc420f7 100644 --- a/features/scaffold.feature +++ b/features/scaffold.feature @@ -116,6 +116,16 @@ Feature: WordPress code scaffolding """ And the return code should be 1 + @theme + Scenario: Scaffold a child theme with a relative --path argument containing '..' + Given a WP install in 'subdir' + And I run `wp --path=subdir theme path` + And save STDOUT as {THEME_DIR} + + When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --path=subdir` from 'subdir/..' + Then the {THEME_DIR}/zombieland/style.css file should exist + And the {THEME_DIR}/zombieland/functions.php file should exist + @theme Scenario: Scaffold a child theme with dots in the slug Given a WP install diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index 448589e8..b81ec7f0 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -986,11 +986,11 @@ static function ( $item ) use ( $slug ) { private function check_target_directory( $type, $target_dir ) { $parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) ); - if ( 'theme' === $type && str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) !== $parent_dir ) { + if ( 'theme' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) ) !== $parent_dir ) { return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_CONTENT_DIR . '/themes' ); } - if ( 'plugin' === $type && str_replace( '\\', '/', WP_PLUGIN_DIR ) !== $parent_dir ) { + if ( 'plugin' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) !== $parent_dir ) { return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_PLUGIN_DIR ); } From b6098a48673a02293e26f1d51de2d9c5e870c0d4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 21 Apr 2026 13:42:08 +0200 Subject: [PATCH 3/4] Update features/scaffold.feature Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- features/scaffold.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/scaffold.feature b/features/scaffold.feature index 5dc420f7..2cf2b0a5 100644 --- a/features/scaffold.feature +++ b/features/scaffold.feature @@ -119,10 +119,10 @@ Feature: WordPress code scaffolding @theme Scenario: Scaffold a child theme with a relative --path argument containing '..' Given a WP install in 'subdir' - And I run `wp --path=subdir theme path` + And I run `wp --path=.. theme path` from 'subdir/wp-content' And save STDOUT as {THEME_DIR} - When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --path=subdir` from 'subdir/..' + When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --path=..` from 'subdir/wp-content' Then the {THEME_DIR}/zombieland/style.css file should exist And the {THEME_DIR}/zombieland/functions.php file should exist From 41e26ec930b7e6dcdb38266dfc233f80a30e8b76 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:44:43 +0000 Subject: [PATCH 4/4] Use canonicalized paths in check_target_directory error messages Agent-Logs-Url: https://github.com/wp-cli/scaffold-command/sessions/a8984726-09d4-4601-bb50-2e88ba9310de Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Scaffold_Command.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index b81ec7f0..f1a3e6be 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -986,12 +986,14 @@ static function ( $item ) use ( $slug ) { private function check_target_directory( $type, $target_dir ) { $parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) ); - if ( 'theme' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) ) !== $parent_dir ) { - return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_CONTENT_DIR . '/themes' ); + $themes_dir = self::canonicalize_path( str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) ); + if ( 'theme' === $type && $themes_dir !== $parent_dir ) { + return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, $themes_dir ); } - if ( 'plugin' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) !== $parent_dir ) { - return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_PLUGIN_DIR ); + $plugins_dir = self::canonicalize_path( str_replace( '\\', '/', WP_PLUGIN_DIR ) ); + if ( 'plugin' === $type && $plugins_dir !== $parent_dir ) { + return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, $plugins_dir ); } // Success.