STATUS_COMPLETE
STATUS_COMPLETE = 'complete'
Class ActionScheduler_wpPostStore
$max_args_length : int
Maximum length of args.
$store : \ActionScheduler_Store
ActionScheduler_Store instance.
$claim_before_date : \DateTime|null
Used to share information about the before_date property of claims internally.
This is used in preference to passing the same information as a method param for backwards-compatibility reasons.
save_action(\ActionScheduler_Action $action, \DateTime|null $scheduled_date = null) : int
Save action.
\ActionScheduler_Action | $action | Scheduled Action. |
\DateTime|null | $scheduled_date | Scheduled Date. |
Throws an exception if the action could not be saved.
find_action(string $hook, array $params = array()) : string|null
Find an action.
Note: the query ordering changes based on the passed 'status' value.
string | $hook | Action hook. |
array | $params | Parameters of the action to find. |
ID of the next action matching the criteria or NULL if not found.
query_actions(array $query = array(), string $query_type = 'select') : string|array|null
Query for action count or list of action IDs.
array | $query | Query filtering options. |
string | $query_type | Whether to select or count the results. Defaults to select. |
The IDs of actions matching the query. Null on failure.
stake_claim(int $max_actions = 10, \DateTime|null $before_date = null, array $hooks = array(), string $group = '') : \ActionScheduler_ActionClaim
Stake claim.
int | $max_actions | Maximum number of actions. |
\DateTime|null | $before_date | Jobs must be schedule before this date. Defaults to now. |
array | $hooks | Claim only actions with a hook or hooks. |
string | $group | Claim only actions in the given group. |
When there is an error staking a claim.
When the given group is not valid.
set_unique_post_slug(string $override_slug, string $slug, int $post_ID, string $post_status, string $post_type) : string
Create a (probably unique) post name for scheduled actions in a more performant manner than wp_unique_post_slug().
When an action's post status is transitioned to something other than 'draft', 'pending' or 'auto-draft, like 'publish' or 'failed' or 'trash', WordPress will find a unique slug (stored in post_name column) using the wp_unique_post_slug() function. This is done to ensure URL uniqueness. The approach taken by wp_unique_post_slug() is to iterate over existing post_name values that match, and append a number 1 greater than the largest. This makes sense when manually creating a post from the Edit Post screen. It becomes a bottleneck when automatically processing thousands of actions, with a database containing thousands of related post_name values.
WordPress 5.1 introduces the 'pre_wp_unique_post_slug' filter for plugins to address this issue.
We can short-circuit WordPress's wp_unique_post_slug() approach using the 'pre_wp_unique_post_slug' filter. This method is available to be used as a callback on that filter. It provides a more scalable approach to generating a post_name/slug that is probably unique. Because Action Scheduler never actually uses the post_name field, or an action's slug, being probably unique is good enough.
For more backstory on this issue, see:
string | $override_slug | Short-circuit return value. |
string | $slug | The desired slug (post_name). |
int | $post_ID | Post ID. |
string | $post_status | The post status. |
string | $post_type | Post type. |
get_scheduled_date_string(\ActionScheduler_Action $action, null|\DateTime $scheduled_date = null) : string
Get the time MySQL formatted date/time string for an action's (next) scheduled date.
\ActionScheduler_Action | $action | Action. |
null|\DateTime | $scheduled_date | Action's schedule date (optional). |
get_scheduled_date_string_local(\ActionScheduler_Action|null $action, null|\DateTime $scheduled_date = null) : string
Get the time MySQL formatted date/time string for an action's (next) scheduled date.
\ActionScheduler_Action|null | $action | Action. |
null|\DateTime | $scheduled_date | Action's scheduled date (optional). |
validate_schedule(mixed $schedule, int $action_id) : mixed
Validate a ActionScheduler_Schedule object.
mixed | $schedule | The unserialized ActionScheduler_Schedule object. |
int | $action_id | The action ID. |
When the schedule is invalid.
validate_action(\ActionScheduler_Action $action) : mixed
InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However, as we prepare to move to custom tables, and can use an indexed VARCHAR column instead, we want to warn developers of this impending requirement.
\ActionScheduler_Action | $action | Action object. |
create_post_array(\ActionScheduler_Action $action, \DateTime|null $scheduled_date = null) : array
Create post array.
\ActionScheduler_Action | $action | Scheduled Action. |
\DateTime|null | $scheduled_date | Scheduled Date. |
Returns an array of post data.
None found |
save_post_array(array $post_array) : int
Save post array.
array | $post_array | Post array. |
Throws an exception if the action could not be saved.
Returns the post ID.
None found |
save_post_schedule(int $post_id, string $schedule) : void
Save post schedule.
int | $post_id | Post ID of the scheduled action. |
string | $schedule | Schedule to save. |
None found |
save_action_group(int $post_id, string $group) : void
Save action group.
int | $post_id | Post ID. |
string | $group | Group to save. |
None found |
get_post(string $action_id) : \WP_Post|null
Get post.
string | $action_id |
|
None found |
get_null_action() : \ActionScheduler_NullAction
Get NULL action.
None found |
make_action_from_post(\WP_Post $post) : \WP_Post
Make action from post.
\WP_Post | $post | Post object. |
None found |
get_action_status_by_post_status(string $post_status) : string
Get action status by post status.
string | $post_status | Post status. |
Throw InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels().
None found |
get_post_status_by_action_status(string $action_status) : string
Get post status by action status.
string | $action_status | Action status. |
Throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels().
None found |
get_query_actions_sql(array $query, string $select_or_count = 'select') : string
Returns the SQL statement to query (or count) actions.
array | $query |
|
string | $select_or_count |
|
SQL statement. The returned SQL is already properly escaped.
None found |
None found |
claim_actions(string $claim_id, int $limit, \DateTime|null $before_date = null, array $hooks = array(), string $group = '') : int
Claim actions.
string | $claim_id | Claim ID. |
int | $limit | Limit. |
\DateTime|null | $before_date | Should use UTC timezone. |
array | $hooks | Claim only actions with a hook or hooks. |
string | $group | Claim only actions in the given group. |
When there is a database error.
The number of actions that were claimed.
None found |
get_actions_by_group(string $group, int $limit, \DateTime $date) : array
Get IDs of actions within a certain group and up to a certain date/time.
string | $group | The group to use in finding actions. |
int | $limit | The number of actions to retrieve. |
\DateTime | $date | DateTime object representing cutoff time for actions. Actions retrieved will be up to and including this DateTime. |
When the group does not exist.
IDs of actions in the appropriate group and before the appropriate time.
None found |
bulk_cancel_actions(int[] $action_ids) : void
Cancel a set of action IDs.
int[] | $action_ids | List of action IDs. |
since | 3.0.0 |
---|
get_post_column(string $action_id, string $column_name) : string|null
Get post column
string | $action_id | Action ID. |
string | $column_name | Column Name. |
None found |