Skip to content

Commit 006b8bc

Browse files
committed
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.
1 parent 1f42cac commit 006b8bc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Scaffold_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,11 @@ static function ( $item ) use ( $slug ) {
986986
private function check_target_directory( $type, $target_dir ) {
987987
$parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) );
988988

989-
if ( 'theme' === $type && str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) !== $parent_dir ) {
989+
if ( 'theme' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) ) !== $parent_dir ) {
990990
return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_CONTENT_DIR . '/themes' );
991991
}
992992

993-
if ( 'plugin' === $type && str_replace( '\\', '/', WP_PLUGIN_DIR ) !== $parent_dir ) {
993+
if ( 'plugin' === $type && self::canonicalize_path( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) !== $parent_dir ) {
994994
return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_PLUGIN_DIR );
995995
}
996996

0 commit comments

Comments
 (0)