Skip to content

Instantly share code, notes, and snippets.

@nathan-roberts
Created November 18, 2024 10:25
Show Gist options
  • Select an option

  • Save nathan-roberts/95521ce11e47a3f6aeceb6f549d120b6 to your computer and use it in GitHub Desktop.

Select an option

Save nathan-roberts/95521ce11e47a3f6aeceb6f549d120b6 to your computer and use it in GitHub Desktop.

Revisions

  1. nathan-roberts created this gist Nov 18, 2024.
    23 changes: 23 additions & 0 deletions action-scheduler-test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <?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.";
    }