Skip to content

Commit 2fe5db4

Browse files
committed
use wp_doing_cron() instead of constant checking (#44)
The function is available since WP 4.8 and defaults to the same logic but applies an additional filter internally.
1 parent 8c327cc commit 2fe5db4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

inc/class-statifyblacklist-admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ public static function plugin_actions_links( array $links, string $file ): array
126126
*/
127127
public static function cleanup_database(): void {
128128
// Check user permissions.
129-
if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
129+
if ( ! current_user_can( 'manage_options' ) && ! wp_doing_cron() ) {
130130
die( esc_html__( 'Are you sure you want to do this?', 'statify-blacklist' ) );
131131
}
132132

133-
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
133+
if ( wp_doing_cron() ) {
134134
$clean_ref = ( 1 === self::$options['referer']['cron'] );
135135
$clean_trg = ( 1 === self::$options['target']['cron'] );
136136
} else {

inc/class-statifyblacklist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static function init(): void {
109109
}
110110

111111
// CronJob to clean up database.
112-
if ( defined( 'DOING_CRON' ) && DOING_CRON &&
112+
if ( wp_doing_cron() &&
113113
( 1 === self::$options['referer']['cron'] || 1 === self::$options['target']['cron'] ) ) {
114114
add_action( 'statify_cleanup', array( 'StatifyBlacklist_Admin', 'cleanup_database' ) );
115115
}

0 commit comments

Comments
 (0)