\Action_Scheduler\WP_CLI\ActionGenerate_Command

WP-CLI command: action-scheduler action generate

Summary

Methods
Properties
Constants
__construct()
execute()
No public properties found
DATE_FORMAT
get_schedule_display_string()
process_csv_arguments_to_arrays()
generate()
print_success()
print_error()
$args
$assoc_args
N/A
No private methods found
No private properties found
N/A

Constants

DATE_FORMAT

DATE_FORMAT = 'Y-m-d H:i:s O'

Properties

$args

$args : string[]

Keyed arguments.

Type

normal

$assoc_args

$assoc_args : array<string,string>

Positional arguments.

Type

normal

Methods

__construct()

__construct(string[]  $args, array<string,string>  $assoc_args) : mixed

Construct.

Parameters

string[] $args

Positional arguments.

array $assoc_args

Keyed arguments.

Throws

\Exception

When loading a CLI command file outside of WP CLI context.

Returns

mixed

execute()

execute() : void

Execute command.

get_schedule_display_string()

get_schedule_display_string(\ActionScheduler_Schedule  $schedule) : string

Get the scheduled date in a human friendly format.

Parameters

\ActionScheduler_Schedule $schedule

Schedule.

Returns

string

process_csv_arguments_to_arrays()

process_csv_arguments_to_arrays() : void

Transforms arguments with '__' from CSV into expected arrays.

generate()

generate(int  $schedule_start, int  $interval, int  $count, string  $hook, array  $args = array(), string  $group = '') : int[]

Schedule multiple single actions.

Parameters

int $schedule_start

Starting timestamp of first action.

int $interval

How long to wait between runs.

int $count

Limit number of actions to schedule.

string $hook

The hook to trigger.

array $args

Arguments to pass when the hook triggers.

string $group

The group to assign this job to.

Returns

int[] —

IDs of actions added.

print_success()

print_success(int  $actions_added, string  $action_type) : void

Print a success message with the action ID.

Parameters

int $actions_added

Number of actions generated.

string $action_type

Type of actions scheduled.

print_error()

print_error(\Exception  $e) : void

Convert an exception into a WP CLI error.

Parameters

\Exception $e

The error object.

Throws

\WP_CLI\ExitException

When an error occurs.