Skip to content

Instantly share code, notes, and snippets.

@nathan-roberts
Created November 18, 2024 10:25
Show Gist options
  • Save nathan-roberts/95521ce11e47a3f6aeceb6f549d120b6 to your computer and use it in GitHub Desktop.
Save nathan-roberts/95521ce11e47a3f6aeceb6f549d120b6 to your computer and use it in GitHub Desktop.
Action Scheduler Test Run Script
<?php
require_once('wp-load.php');
// Load the Action Scheduler library
if (class_exists('ActionScheduler')) {
$action_id = 11;
$sql = "UPDATE `local`.`wp_actionscheduler_actions` SET `status` = 'pending' WHERE `action_id` = " . $action_id . ";";
$result = $wpdb->query($sql);
// Get the action object by ID
$action = \ActionScheduler::store()->fetch_action($action_id);
var_dump($action);
if ($action) {
// Execute the action
$action->execute();
echo "Action with ID $action_id has been executed.";
} else {
echo "Action with ID $action_id not found.";
}
} else {
echo "Action Scheduler class not found.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment