public function schedule( $args, $assoc_args ) {

		$hook       = $args[0];
		$next_run   = Utils\get_flag_value( $args, 1, 'now' );
		$recurrence = Utils\get_flag_value( $args, 2, false );

		if ( empty( $next_run ) ) {
			$timestamp = time();
		} elseif ( is_numeric( $next_run ) ) {
			$timestamp = absint( $next_run );
		} else {
			$timestamp = strtotime( $next_run );
		}

		if ( ! $timestamp ) {
			WP_CLI::error( sprintf( "'%s' is not a valid datetime.", $next_run ) );
		}

		if ( ! empty( $recurrence ) ) {

			$schedules = wp_get_schedules();

			if ( ! isset( $schedules[ $recurrence ] ) ) {
				WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) );
			}

			$event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args );

		} else {

			$event = wp_schedule_single_event( $timestamp, $hook, $assoc_args );

		}

		if ( false !== $event ) {
			WP_CLI::success( sprintf( "Scheduled event with hook '%s' for %s GMT.", $hook, date( self::$time_format, $timestamp ) ) );
		} else {
			WP_CLI::error( 'Event not scheduled.' );
		}

	}
public function schedule( $args, $assoc_args ) {

		$hook       = $args[0];
		$next_run   = Utils\get_flag_value( $args, 1, 'now' );
		$recurrence = Utils\get_flag_value( $args, 2, false );

		if ( empty( $next_run ) ) {
			$timestamp = time();
		} elseif ( is_numeric( $next_run ) ) {
			$timestamp = absint( $next_run );
		} else {
			$timestamp = strtotime( $next_run );
		}

		if ( ! $timestamp ) {
			WP_CLI::error( sprintf( "'%s' is not a valid datetime.", $next_run ) );
		}

		if ( ! empty( $recurrence ) ) {

			$schedules = wp_get_schedules();

			if ( ! isset( $schedules[ $recurrence ] ) ) {
				WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) );
			}

			$event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args );

		} else {

			$event = wp_schedule_single_event( $timestamp, $hook, $assoc_args );

		}

		if ( false !== $event ) {
			WP_CLI::success( sprintf( "Scheduled event with hook '%s' for %s GMT.", $hook, date( self::$time_format, $timestamp ) ) );
		} else {
			WP_CLI::error( 'Event not scheduled.' );
		}

	}
public function schedule ( $ args , $ assoc_args ) { $ hook = $ args [ 0 ] ; $ next_run = Utils \ get_flag_value ( $ args , 1 , 'now' ) ; $ recurrence = Utils \ get_flag_value ( $ args , 2 , false ) ; if ( empty ( $ next_run ) ) { $ timestamp = time ( ) ; } elseif ( is_numeric ( $ next_run ) ) { $ timestamp = absint ( $ next_run ) ; } else { $ timestamp = strtotime ( $ next_run ) ; } if ( ! $ timestamp ) { WP_CLI :: error ( sprintf ( "'%s' is not a valid datetime." , $ next_run ) ) ; } if ( ! empty ( $ recurrence ) ) { $ schedules = wp_get_schedules ( ) ; if ( ! isset ( $ schedules [ $ recurrence ] ) ) { WP_CLI :: error ( sprintf ( "'%s' is not a valid schedule name for recurrence." , $ recurrence ) ) ; } $ event = wp_schedule_event ( $ timestamp , $ recurrence , $ hook , $ assoc_args ) ; } else { $ event = wp_schedule_single_event ( $ timestamp , $ hook , $ assoc_args ) ; } if ( false !== $ event ) { WP_CLI :: success ( sprintf ( "Scheduled event with hook '%s' for %s GMT." , $ hook , date ( self :: $ time_format , $ timestamp ) ) ) ; } else { WP_CLI :: error ( 'Event not scheduled.' ) ; } }
Schedules a new cron event.

## OPTIONS

<hook>
: The hook name.

[<next-run>]
: A Unix timestamp or an English textual datetime description compatible with `strtotime()`. Defaults to now.

[<recurrence>]
: How often the event should recur. See `wp cron schedule list` for available schedule names. Defaults to no recurrence.

[--<field>=<value>]
: Associative args for the event.

## EXAMPLES

# Schedule a new cron event
$ wp cron event schedule cron_test
Success: Scheduled event with hook 'cron_test' for 2016-05-31 10:19:16 GMT.

# Schedule new cron event with hourly recurrence
$ wp cron event schedule cron_test now hourly
Success: Scheduled event with hook 'cron_test' for 2016-05-31 10:20:32 GMT.

# Schedule new cron event and pass associative arguments
$ wp cron event schedule cron_test '+1 hour' --foo=1 --bar=2
Success: Scheduled event with hook 'cron_test' for 2016-05-31 11:21:35 GMT.
Schedules a new cron event .