PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / jobs / module.php
jetformbuilder / modules / jobs Last commit date
interfaces 2 years ago traits 2 years ago async-job.php 2 years ago module.php 2 years ago once-job.php 2 years ago recurring-job.php 2 years ago
module.php
107 lines
1 <?php
2
3
4 namespace JFB_Modules\Jobs;
5
6 use Jet_Form_Builder\Exceptions\Repository_Exception;
7 use JFB_Components\Module\Base_Module_After_Install_It;
8 use JFB_Components\Module\Base_Module_It;
9 use JFB_Components\Repository\Interfaces\Repository_Pattern_Interface;
10 use JFB_Components\Repository\Repository_Pattern_Trait;
11 use JFB_Modules\Jobs\Interfaces\Self_Execution_Job_It;
12 use JFB_Modules\Post_Type;
13
14 // If this file is called directly, abort.
15 if ( ! defined( 'WPINC' ) ) {
16 die();
17 }
18
19 final class Module implements
20 Base_Module_It,
21 Base_Module_After_Install_It,
22 Repository_Pattern_Interface {
23
24 use Repository_Pattern_Trait;
25
26 private $action_id = 0;
27
28 public function rep_item_id() {
29 return 'jobs';
30 }
31
32 public function condition(): bool {
33 return true;
34 }
35
36 public function on_install() {
37 $this->rep_install();
38 }
39
40 public function on_uninstall() {
41 $this->rep_clear();
42 }
43
44 public function init_hooks() {
45 /** @var Self_Execution_Job_It $job */
46 foreach ( $this->rep_generate_items() as $job ) {
47 $job->init_hooks();
48 }
49 add_action(
50 'action_scheduler_begin_execute',
51 array( $this, 'set_action_id' )
52 );
53 }
54
55 public function remove_hooks() {
56 /** @var Self_Execution_Job_It $job */
57 foreach ( $this->rep_generate_items() as $job ) {
58 $job->remove_hooks();
59 }
60 remove_action(
61 'action_scheduler_begin_execute',
62 array( $this, 'set_action_id' )
63 );
64 }
65
66 public function rep_instances(): array {
67 return array();
68 }
69
70 public function unschedule_all() {
71 if ( ! class_exists( '\ActionScheduler_DBStore' ) ) {
72 return;
73 }
74
75 \ActionScheduler_DBStore::instance()->cancel_actions_by_group( Post_Type\Module::SLUG );
76 }
77
78 public function set_action_id( $action_id ) {
79 $this->action_id = absint( $action_id );
80 }
81
82 /**
83 * @return int
84 */
85 public function get_action_id(): int {
86 return $this->action_id;
87 }
88
89 public function install( Self_Execution_Job_It $job ) {
90 $this->rep_install_item_soft( $job );
91 }
92
93 public function uninstall( Self_Execution_Job_It $job ) {
94 $this->rep_remove( $job );
95 }
96
97 /**
98 * @param string $job_hook
99 *
100 * @return Self_Execution_Job_It
101 * @throws Repository_Exception
102 */
103 public function get( string $job_hook ): Self_Execution_Job_It {
104 return $this->rep_get_item( $job_hook );
105 }
106 }
107