diff --git a/includes/functions.php b/includes/functions.php index 08d7271631051159fbff94d47d758e09f443f1f8..10676452238733eb2002cdc49b15743b9c046a93 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -5,16 +5,22 @@ namespace Automattic\WP\WP_CLI_Cron_Control_Offload; /** * Create cron event for a given WP-CLI command * - * return bool|\WP_Error + * @param string $args + * @param int $timestamp Optional. + * @return bool|\WP_Error */ -function schedule_cli_command( $args ) { +function schedule_cli_command( $args, $timestamp = null ) { $event_args = validate_args( $args ); if ( is_wp_error( $event_args ) ) { return $event_args; } - $scheduled = wp_schedule_single_event( strtotime( '+30 seconds' ), ACTION, array( 'command' => $event_args ) ); + if ( ! is_int( $timestamp ) ) { + $timestamp = strtotime( '+30 seconds' ); + } + + $scheduled = wp_schedule_single_event( $timestamp, ACTION, array( 'command' => $event_args ) ); return false !== $scheduled; }