File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,6 +116,16 @@ Feature: WordPress code scaffolding
116116 """
117117 And the return code should be 1
118118
119+ @theme
120+ Scenario : Scaffold a child theme with a relative --path argument containing '..'
121+ Given a WP install in 'subdir'
122+ And I run `wp --path=.. theme path` from 'subdir/wp-content'
123+ And save STDOUT as {THEME_DIR}
124+
125+ When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --path=..` from 'subdir/wp-content'
126+ Then the {THEME_DIR}/zombieland/style.css file should exist
127+ And the {THEME_DIR}/zombieland/functions.php file should exist
128+
119129 @theme
120130 Scenario : Scaffold a child theme with dots in the slug
121131 Given a WP install
Original file line number Diff line number Diff line change @@ -986,12 +986,14 @@ 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 ) {
990- return sprintf ( 'The target directory \'%1$s \' is not in \'%2$s \'. ' , $ target_dir , WP_CONTENT_DIR . '/themes ' );
989+ $ themes_dir = self ::canonicalize_path ( str_replace ( '\\' , '/ ' , WP_CONTENT_DIR . '/themes ' ) );
990+ if ( 'theme ' === $ type && $ themes_dir !== $ parent_dir ) {
991+ return sprintf ( 'The target directory \'%1$s \' is not in \'%2$s \'. ' , $ target_dir , $ themes_dir );
991992 }
992993
993- if ( 'plugin ' === $ type && str_replace ( '\\' , '/ ' , WP_PLUGIN_DIR ) !== $ parent_dir ) {
994- return sprintf ( 'The target directory \'%1$s \' is not in \'%2$s \'. ' , $ target_dir , WP_PLUGIN_DIR );
994+ $ plugins_dir = self ::canonicalize_path ( str_replace ( '\\' , '/ ' , WP_PLUGIN_DIR ) );
995+ if ( 'plugin ' === $ type && $ plugins_dir !== $ parent_dir ) {
996+ return sprintf ( 'The target directory \'%1$s \' is not in \'%2$s \'. ' , $ target_dir , $ plugins_dir );
995997 }
996998
997999 // Success.
You can’t perform that action at this time.
0 commit comments