From 27b2abe428ff068959af61025f701ae4f360fe05 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Fri, 8 Sep 2017 13:15:50 -0700 Subject: [PATCH] Allow future-dated execution --- includes/functions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 08d7271..1067645 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; } -- GitLab