File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed
Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,9 @@ function __construct( $args ) {
5959 * @return void
6060 */
6161 public function schedule_event () {
62- $ find = false ;
63- $ crons = _get_cron_array ();
64- if ( !empty ( $ crons ) ) {
65- foreach ( $ crons as $ timestamp => $ cron ) {
66- if ( isset ( $ cron [ $ this ->args [ 'name ' ] ] ) ) {
67- $ find = true ;
68- }
62+ if ($ this ->isScheduled ($ this ->args ['name ' ], _get_cron_array ())) {
63+ return ;
6964 }
70- }
71- if ( !$ find ) {
7265 if ( $ this ->args [ 'run_on_creation ' ] ) {
7366 call_user_func ( $ this ->args [ 'cb ' ], $ this ->args [ 'args ' ] );
7467 }
@@ -84,7 +77,6 @@ public function schedule_event() {
8477 $ sites [] = get_current_blog_id ();
8578 update_site_option ( $ this ->args [ 'name ' ] . '_sites ' , $ sites );
8679 }
87- }
8880 }
8981
9082 /**
@@ -137,4 +129,24 @@ public function deactivate() {
137129 delete_site_option ( $ this ->args [ 'name ' ] . '_sites ' );
138130 }
139131
132+ /**
133+ * @param string $name
134+ * @param array $crons
135+ * @return bool
136+ */
137+ private function isScheduled ($ name , $ crons )
138+ {
139+ if (empty ($ crons )) {
140+ return false ;
141+ }
142+
143+ foreach ($ crons as $ cron ) {
144+ if (isset ($ cron [$ name ])) {
145+ return true ;
146+ }
147+ }
148+
149+ return false ;
150+ }
151+
140152}
You can’t perform that action at this time.
0 commit comments