Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created November 18, 2022 16:50
Show Gist options
  • Save danielbachhuber/2951826b5cee4db3c8245ff095d5b7de to your computer and use it in GitHub Desktop.
Save danielbachhuber/2951826b5cee4db3c8245ff095d5b7de to your computer and use it in GitHub Desktop.
diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php
index cb070708..203ed567 100644
--- a/src/Scaffold_Command.php
+++ b/src/Scaffold_Command.php
@@ -958,12 +958,17 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
*/
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 && (
+ realpath( str_replace( '\\', '/', WP_CONTENT_DIR . '/themes' ) ) !== $parent_dir &&
+ 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 && (
+ realpath( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) !== $parent_dir &&
+ str_replace( '\\', '/', WP_PLUGIN_DIR ) !== $parent_dir
+ ) ) {
return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_PLUGIN_DIR );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment