Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid theme slug specified. The target directory #263

Closed
NickStallman opened this issue May 8, 2020 · 1 comment
Closed

Invalid theme slug specified. The target directory #263

NickStallman opened this issue May 8, 2020 · 1 comment

Comments

@NickStallman
Copy link

I'm hitting this Invalid theme slug issue when I am running wp-cli from a different folder to the Wordpress installation.

My full command is:

./vendor/bin/wp scaffold child-theme child-testchild4 --path=../testchild4 --parent_theme='the-parent-theme' --theme_name='test child 4' --activate

The full error is:
Error: Invalid theme slug specified. The target directory '/home/apweb/public_html/deploy/../testchild4/wp-content/themes/apb-evolve-testchild4' is not in '/home/apweb/public_html/deploy/../testchild4/wp-content/themes'
I am running the command from the "deploy" folder, and my WP install is in ../testchild4.

The path:
/home/apweb/public_html/deploy/../testchild4/wp-content/themes/apb-evolve-testchild4
Is certainly inside:
/home/apweb/public_html/deploy/../testchild4/wp-content/themes

I traced the issue to Scaffold_Command.php in check_target_directory() and in this case $parent_dir is:
/home/apweb/public_html/testchild4/wp-content/themes.

So the string match is failing, but it's the exact same folder.
Wrapping the str_replace() path with realpath() fixes this issue.

NielsdeBlaauw added a commit to NielsdeBlaauw/scaffold-command that referenced this issue Jun 2, 2022
parent_dir contains a normalized path whereas  WP_CONTENT_DIR contains a relative path. By running the WP_CONTENT_DIR through realpath we get a path we can actually compare between the target dir and where we want to place the new theme.

Also fixes wp-cli#251
@swissspidy
Copy link
Member

Looks like this is a duplicate of #251, so closing this one as a duplicate. Definitely still worth fixing 👍

@swissspidy swissspidy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants