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"}]
Afficher le fichier
Open project: wp-cli/wp-cli
Méthodes publiques
Méthode |
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. |
|
Méthodes protégées
Private Methods
Method Details
## 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 méthode
protected static delete_event ( stdClass $event ) : boolean |
$event |
stdClass |
The event |
Résultat |
boolean |
Whether the event was successfully deleted or not. |
get_cron_events()
protected static méthode
Fetch an array of scheduled cron events.
protected static get_cron_events ( ) : array | WP_Error |
Résultat |
array | WP_Error |
An array of event objects, or a WP_Error object if there are no events scheduled. |
## 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 ) |
## 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 méthode
Executes an event immediately.
protected static run_event ( stdClass $event ) : boolean |
$event |
stdClass |
The event |
Résultat |
boolean |
Whether the event was successfully executed or not. |
schedule()
public méthode
## 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.