Closed icodus closed 1 year ago
Sorry, I don't quite understand the issue. Did you see this error or are you asking if it's possible?
If you've experienced an error, please provide more detail as to the context, including the full error message and trace if possible. Thanks 👍
VS Code shows "Undefined constant 'WP_CLI_Login\WP_CLI" error. Seems logical to me. Adding if (!defined('WP_CLI')) { define('WP_CLI', 'false'); } clears the error.
Glad to hear there is no error 😄
The usage you're referring to is safe because it checks that the constant is defined before using it https://github.com/aaemnnosttv/wp-cli-login-command/blob/ab20aee280de98974ac5b22b635c533d41faf296/plugin/wp-cli-login-server.php#L35
It sounds like VS Code is complaining because the code is in the WP_CLI_Login
namespace but will fall back to the global constant since it isn't defined in this namespace. The defined
check will always reference the global namespace though.
The plugin shouldn't define a constant that is only intended to be defined by WP CLI but that would fix the usage it's complaining about.
Thanks for your interest in contributing. Cheers!
If "WP_CLI" is not defined in wp-cli-login-server.php ( not called from wp_cli ) then the line (defined('WP_CLI') && WP_CLI) is trying to use undefined WP_CLI constant or I'm missing something obvious?