-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Action Scheduler controller to keep track of AS tasks via `PRONAM…
…IC_ACTION_SCHEDULER_CONTEXT` define.
- Loading branch information
1 parent
af402e0
commit b1c28b0
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Action Scheduler Controller | ||
* | ||
* @author Pronamic <info@pronamic.eu> | ||
* @copyright 2005-2023 Pronamic | ||
* @license GPL-3.0-or-later | ||
* @package Pronamic\WordPress\Pay | ||
*/ | ||
|
||
namespace Pronamic\WordPress\Pay; | ||
|
||
/** | ||
* Action Scheduler Controller class | ||
*/ | ||
class ActionSchedulerController { | ||
/** | ||
* Setup. | ||
* | ||
* @return void | ||
*/ | ||
public function setup() { | ||
\add_action( 'action_scheduler_begin_execute', [ $this, 'begin_execute' ], 10, 2 ); | ||
} | ||
|
||
/** | ||
* Action scheduler begin execute. | ||
* | ||
* @link https://github.com/woocommerce/action-scheduler/blob/3.7.1/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php#L84 | ||
* @param int $action_id Action ID. | ||
* @param string $context Context. | ||
* @return void | ||
*/ | ||
public function begin_execute( $action_id, $context ) { | ||
if ( \defined( 'PRONAMIC_ACTION_SCHEDULER_CONTEXT' ) ) { | ||
return; | ||
} | ||
|
||
\define( 'PRONAMIC_ACTION_SCHEDULER_CONTEXT', $context ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters