PHP Class Cron_Event_Command, wp-cli

## 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. # Run all cron events due right now $ wp cron event run --due-now Success: Executed a total of 2 cron events. # Delete the next scheduled cron event $ wp cron event delete cron_test Success: Deleted 2 instances of the cron event 'cron_test'. # List scheduled cron events in JSON $ wp cron event list --fields=hook,next_run --format=json [{"hook":"wp_version_check","next_run":"2016-05-31 10:15:13"},{"hook":"wp_update_plugins","next_run":"2016-05-31 10:15:13"},{"hook":"wp_update_themes","next_run":"2016-05-31 10:15:14"}]
Inheritance: extends WP_CLI_Command
ファイルを表示 Open project: wp-cli/wp-cli

Public Methods

Method Description
delete ( $args, $assoc_args ) Delete the next scheduled cron event for the given hook.
list_ ( $args, $assoc_args ) List scheduled cron events.
run ( $args, $assoc_args ) Run the next scheduled cron event for the given hook.
schedule ( $args, $assoc_args ) Schedule a new cron event.

Protected Methods

Method Description
delete_event ( stdClass $event ) : boolean Deletes a cron event.
format_event ( stdClass $event ) : stdClass Callback function to format a cron event.
get_cron_events ( ) : array | WP_Error Fetch an array of scheduled cron events.
run_event ( stdClass $event ) : boolean Executes an event immediately.

Private Methods

Method Description
get_formatter ( &$assoc_args )
interval ( integer $since ) : string Convert a time interval into human-readable format.

Method Details

delete() public method

## OPTIONS : The hook name. ## EXAMPLES # Delete the next scheduled cron event $ wp cron event delete cron_test Success: Deleted 2 instances of the cron event 'cron_test'.
public delete ( $args, $assoc_args )

delete_event() protected static method

Deletes a cron event.
protected static delete_event ( stdClass $event ) : boolean
$event stdClass The event
return boolean Whether the event was successfully deleted or not.

format_event() protected static method

Callback function to format a cron event.
protected static format_event ( stdClass $event ) : stdClass
$event stdClass The event.
return stdClass The formatted event object.

get_cron_events() protected static method

Fetch an array of scheduled cron events.
protected static get_cron_events ( ) : array | WP_Error
return array | WP_Error An array of event objects, or a WP_Error object if there are no events scheduled.

list_() public method

## OPTIONS [--fields=] : Limit the output to specific object fields. [--=] : Filter by one or more fields. [--field=] : Prints the value of a single field for each event. [--format=] : Render output in a particular format. --- default: table options: - table - csv - ids - json - count - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each cron event: * hook * next_run_gmt * next_run_relative * recurrence These fields are optionally available: * time * sig * args * schedule * interval * next_run ## EXAMPLES # List scheduled cron events $ wp cron event list +-------------------+---------------------+---------------------+------------+ | hook | next_run_gmt | next_run_relative | recurrence | +-------------------+---------------------+---------------------+------------+ | wp_version_check | 2016-05-31 22:15:13 | 11 hours 57 minutes | 12 hours | | wp_update_plugins | 2016-05-31 22:15:13 | 11 hours 57 minutes | 12 hours | | wp_update_themes | 2016-05-31 22:15:14 | 11 hours 57 minutes | 12 hours | +-------------------+---------------------+---------------------+------------+ # List scheduled cron events in JSON $ wp cron event list --fields=hook,next_run --format=json [{"hook":"wp_version_check","next_run":"2016-05-31 10:15:13"},{"hook":"wp_update_plugins","next_run":"2016-05-31 10:15:13"},{"hook":"wp_update_themes","next_run":"2016-05-31 10:15:14"}]
public list_ ( $args, $assoc_args )

run() public method

## OPTIONS [...] : One or more hooks to run. [--due-now] : Run all hooks due right now. [--all] : Run all hooks. ## EXAMPLES # Run all cron events due right now $ wp cron event run --due-now Success: Executed a total of 2 cron events.
public run ( $args, $assoc_args )

run_event() protected static method

Executes an event immediately.
protected static run_event ( stdClass $event ) : boolean
$event stdClass The event
return boolean Whether the event was successfully executed or not.

schedule() public method

## OPTIONS : The hook name. [] : A Unix timestamp or an English textual datetime description compatible with strtotime(). Defaults to now. [] : How often the event should recur. See wp cron schedule list for available schedule names. Defaults to no recurrence. [--=] : 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.
public schedule ( $args, $assoc_args )