Skip to content

Commit

Permalink
improved detection of cron
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 authored Jul 5, 2017
1 parent 1ae4d32 commit e52f006
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cronplus.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ function __construct( $args ) {
* @return void
*/
public function schedule_event() {
if ( !wp_next_scheduled( $this->args[ 'name' ] ) ) {
$find = false;
$crons = _get_cron_array();
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[ $this->args[ 'name' ]] ) ) {
$find = true;
}
}
if ( !$find && !wp_next_scheduled( $this->args[ 'name' ] ) ) {
if ( $this->args[ 'schedule' ] === 'schedule' ) {
wp_schedule_event( current_time( 'timestamp' ), $this->args[ 'recurrence' ], $this->args[ 'name' ], $this->args[ 'args' ] );
} elseif ( $this->args[ 'schedule' ] === 'single' ) {
Expand Down

0 comments on commit e52f006

Please sign in to comment.