diff --git a/inc/class-statifyblacklist-admin.php b/inc/class-statifyblacklist-admin.php index f257413..f8e320f 100644 --- a/inc/class-statifyblacklist-admin.php +++ b/inc/class-statifyblacklist-admin.php @@ -126,11 +126,11 @@ public static function plugin_actions_links( array $links, string $file ): array */ public static function cleanup_database(): void { // Check user permissions. - if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { + if ( ! current_user_can( 'manage_options' ) && ! wp_doing_cron() ) { die( esc_html__( 'Are you sure you want to do this?', 'statify-blacklist' ) ); } - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { + if ( wp_doing_cron() ) { $clean_ref = ( 1 === self::$options['referer']['cron'] ); $clean_trg = ( 1 === self::$options['target']['cron'] ); } else { diff --git a/inc/class-statifyblacklist.php b/inc/class-statifyblacklist.php index f310892..9b13d5d 100644 --- a/inc/class-statifyblacklist.php +++ b/inc/class-statifyblacklist.php @@ -109,7 +109,7 @@ public static function init(): void { } // CronJob to clean up database. - if ( defined( 'DOING_CRON' ) && DOING_CRON && + if ( wp_doing_cron() && ( 1 === self::$options['referer']['cron'] || 1 === self::$options['target']['cron'] ) ) { add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) ); }