Hi there!
My initial question on this would be what are you actually trying to do?
Hello there!
I’m trying to prevent a function from continue its execution if the current request comes from WP-CLI and the command is neither “plugin list” or “plugin update”
I came up with this solution, it could be cleaner, but it works:
if ( defined( 'WP_CLI' ) ) {
$args = $GLOBALS['argv'] ?? array();
$exit = true;
foreach ( $args as $i => $argument ) {
if ( 'plugin' === $argument && ( 'list' === $args[ $i + 1 ] || 'update' === $args[ $i + 1 ] ) ) {
$exit = false;
break;
}
}
if ( $exit ) {
return;
}
}
-
This reply was modified 1 year, 6 months ago by
faridjc.