From 006b8bc044ef1afd85dd7cc6c071010ed59b724f Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Tue, 21 Apr 2026 16:41:07 +0800 Subject: [PATCH] Fix child-theme/plugin path check when --path contains relative segments When --path includes .. or . segments (e.g. --path=../mysite/), WP_CONTENT_DIR retains the unnormalized path, but check_target_directory() canonicalizes the target_dir before comparing. This mismatch causes false rejection of valid theme/plugin directories. Apply canonicalize_path() to both sides of the comparison so paths with relative segments are resolved consistently. --- src/Scaffold_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ); }