Skip to content

Commit

Permalink
fix: enable Memberships fix cron job only when environment constant i…
Browse files Browse the repository at this point in the history
…s defined (#3087)

* fix: enable Memberships fix cron job only when environment constant is defined

* fix: cleaner conditional
  • Loading branch information
dkoo authored Apr 26, 2024
1 parent 62bda23 commit 5d40297
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions includes/plugins/wc-memberships/class-memberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,12 @@ public static function cron_deactivate() {
public static function cron_init() {
\register_deactivation_hook( NEWSPACK_PLUGIN_FILE, [ __CLASS__, 'cron_deactivate' ] );

if ( ! wp_next_scheduled( self::CRON_HOOK ) ) {
\wp_schedule_event( time(), 'hourly', self::CRON_HOOK );
if ( defined( 'NEWSPACK_ENABLE_MEMBERSHIPS_FIX_CRON' ) && NEWSPACK_ENABLE_MEMBERSHIPS_FIX_CRON ) {
if ( ! wp_next_scheduled( self::CRON_HOOK ) ) {
\wp_schedule_event( time(), 'hourly', self::CRON_HOOK );
}
} else {
self::cron_deactivate();
}
}

Expand Down

0 comments on commit 5d40297

Please sign in to comment.