ActionScheduler_wpPostStore (Legacy WP Posts Store)

ActionScheduler_wpPostStore persists actions as a custom post type (scheduled-action) plus post meta and taxonomy data. It lives in classes/data-stores/ActionScheduler_wpPostStore.php and implements the ActionScheduler_Store interface.

Storage Model

Core Post Record

Actions are stored as posts with:

  • post_type: scheduled-action
  • post_title: action hook
  • post_content: JSON-encoded action args
  • post_status: action status (mapped between post status and action status)
  • post_date_gmt / post_date: scheduled date
  • post_modified_gmt / post_modified: last attempt date for completed actions
  • post_password: claim ID
  • menu_order: attempts count

Post Meta

  • _action_manager_schedule stores the serialized ActionScheduler_Schedule object.

Taxonomy

  • action-group taxonomy stores the action group slug.

Initialization

init() registers:

  • post type via ActionScheduler_wpPostStore_PostTypeRegistrar
  • post statuses via ActionScheduler_wpPostStore_PostStatusRegistrar
  • taxonomy via ActionScheduler_wpPostStore_TaxonomyRegistrar

It also adds the action_scheduler_migration_dependencies_met filter.

Public API

save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null )

Creates a post, saves schedule meta and group taxonomy, and fires:

  • action_scheduler_stored_action

fetch_action( $action_id )

Loads the post, validates args/schedule, and returns ActionScheduler_NullAction on failure.

Triggers:

  • action_scheduler_failed_fetch_action

query_actions( $query = array(), $query_type = 'select' )

Builds a custom SQL query against wp_posts with optional joins for group taxonomy. Supports:

  • hook, args, status, group
  • date / modified date
  • claim filters (post_password)
  • search string
  • ordering and pagination

action_counts()

Uses wp_count_posts() to return counts grouped by action status.

cancel_action( $action_id )

Trashes the post and fires:

  • action_scheduler_canceled_action

delete_action( $action_id )

Deletes the post permanently and fires:

  • action_scheduler_deleted_action

get_date( $action_id )

Returns the local scheduled date when pending, or the last modified date when completed.

get_date_gmt( $action_id )

Returns the GMT date used by get_date().

stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' )

Generates a claim ID, marks matching posts’ post_password, and returns an ActionScheduler_ActionClaim.

get_claim_count()

Counts distinct claim IDs across pending/running actions.

find_actions_by_claim_id( $claim_id )

Returns action IDs for a claim, filtered by the before_date used during claim.

release_claim( ActionScheduler_ActionClaim $claim )

Clears post_password on pending actions in the claim.

unclaim_action( $action_id )

Clears post_password on a single action.

mark_failure( $action_id )

Sets post_status to failed.

get_claim_id( $action_id )

Reads the post_password column.

get_status( $action_id )

Reads the post status and maps it to the action status.

log_execution( $action_id )

Increments menu_order, sets status to in-progress, and updates modified timestamps.

mark_complete( $action_id )

Updates status to publish and fires:

  • action_scheduler_completed_action

mark_migrated( $action_id )

Sets post status to migrated when migration cannot delete the action.

migration_dependencies_met( $setting )

Checks whether args length constraints allow migration to custom tables. Filters the migration eligibility via:

  • action_scheduler_maximum_args_length

Supporting Filters

Store-Level Filters

  • action_scheduler_maximum_args_length — max args length for migration checks

Registration Filters

These are used by the registrar classes invoked in init():

  • action_scheduler_post_type_args — customize post type args
  • action_scheduler_taxonomy_args — customize group taxonomy args
  • action_scheduler_post_status_args — customize post status args
  • action_scheduler_post_status_failed_labels — customize “failed” labels
  • action_scheduler_post_status_running_labels — customize “in-progress” labels

Status Mapping

Action status ↔ post status mappings:

  • completepublish
  • canceledtrash
  • pending, in-progress, failed map directly to post statuses

Data Persistence Summary

  • Hook: post_title
  • Args: post_content (JSON)
  • Schedule: _action_manager_schedule post meta
  • Group: action-group taxonomy
  • Status: post_status
  • Claim ID: post_password
  • Attempts: menu_order
  • Dates: post_date_gmt, post_modified_gmt