returnnewWP_Error('not-scheduled',__('Command may already be scheduled, or it was blocked via the `schedule_event` filter.','wp-cli-cron-control-offload'));
}
return$timestamp;
}
}
/**
/**
* Validate WP-CLI command to be scheduled
* Validate WP-CLI command to be scheduled
*
*
* @param string $command
* @param string $command
* @return array|\WP_Error
* @return array|WP_Error
*/
*/
functionvalidate_command($command){
functionvalidate_command($command){
$command=trim($command);
$command=trim($command);
...
@@ -45,7 +54,7 @@ function validate_command( $command ) {
...
@@ -45,7 +54,7 @@ function validate_command( $command ) {
$first_command=explode(' ',$command);
$first_command=explode(' ',$command);
$first_command=array_shift($first_command);
$first_command=array_shift($first_command);
if(!is_command_allowed($first_command)){
if(!is_command_allowed($first_command)){
returnnew\WP_Error(sprintf(__('%1$s: `%2$s` not allowed','wp-cli-cron-control-offload'),MESSAGE_PREFIX,$first_command));
returnnewWP_Error('blocked-command',sprintf(__('`%1$s` not allowed','wp-cli-cron-control-offload'),$first_command));
}
}
// Don't worry about the user WP-CLI runs as
// Don't worry about the user WP-CLI runs as
...
@@ -57,7 +66,7 @@ function validate_command( $command ) {
...
@@ -57,7 +66,7 @@ function validate_command( $command ) {