wp-cli: wp doesn't fully populate $_SERVER array
UPDATE The actual issue is that $_SERVER is not being fully set up when wp-cli is run. If you put
error_log($_SERVER[‘SERVER_NAME’]);
into wp-config.php and run any wp command, you’ll get a blank line. For my setup, this sets WP_CONTENT_URL and WP_CONTENT_DIR to invalid results, and the command fails.
— original report
According to the docs the taxonomy is supplied as the first option and the term is the second. When I do this using a custom taxonomy, the command fails.
Example: typetax is a properly declared and working custom taxonomy using (the full declaration is omitted for clarity)
register_taxonomy( 'typetax', 'stories', $args );
but when this is run
wp term create typetax 'Banana'
I get an error:
Error: Invalid taxonomy
If I run
wp term create post_tag 'Banana'
it works. So the issue seems to be that WP-CLI doesn’t understand Custom Taxonomies.
The CT is declared via an mu-plugin FTR.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (4 by maintainers)
EDIT: Using a switch wasn’t working for wp-admin URLs because the basename was outputting wp-admin. Using if and strstr to check if the cwd had a string in it works for both wp-admin and the live site. It feels clunky but it’s an option.
In case anyone’s looking for a workaround: getcwd() will get the current path and works in php cli php4+. Note that when accessing wp-admin it includes wp-admin because these requests aren’t handled by the index.php in the wordpress root. That’s why I’m using strstr to check if my path exists in the string.
Depending on your environment directory naming scheme this can work for multiple wp-config.php settings.
wp-config.php in case it’s relevant