From d8300adc6f0b41e12a4a7e96c83345c14a1739b9 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Thu, 21 Nov 2024 14:00:08 +0100 Subject: [PATCH] Add a check whether the cron job is enabled --- includes/class-admin.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/includes/class-admin.php b/includes/class-admin.php index ed5518cc..2f86668a 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -3447,6 +3447,10 @@ public function site_status_tests( $tests ) { 'label' => __( 'Friend roles were created', 'friends' ), 'test' => array( $this, 'friend_roles_test' ), ); + $tests['direct']['friends-cron'] = array( + 'label' => __( 'Friend cron job is enabled', 'friends' ), + 'test' => array( $this, 'friends_cron_test' ), + ); return $tests; } @@ -3513,6 +3517,39 @@ public function friend_roles_test() { return $result; } + public function friends_cron_test() { + $result = array( + 'label' => __( 'The friend cron job is enabled', 'friends' ), + 'status' => 'good', + 'badge' => array( + 'label' => __( 'Friends', 'friends' ), + 'color' => 'green', + ), + 'description' => + '

' . + __( 'The Friends Plugin uses a cron job to fetch your friends\' feeds.', 'friends' ) . + '

', + 'test' => 'friends-cron', + ); + + if ( ! wp_next_scheduled( 'cron_friends_refresh_feeds' ) ) { + $result['label'] = __( 'The friends cron job is not enabled', 'friends' ); + $result['badge']['color'] = 'red'; + $result['status'] = 'critical'; + $result['description'] .= '

'; + $result['description'] .= wp_kses_post( + sprintf( + // translators: %s is a URL. + __( 'To fix this: Enable the Friends cron job.', 'friends' ), + esc_url( wp_nonce_url( add_query_arg( '_wp_http_referer', remove_query_arg( '_wp_http_referer' ), self_admin_url( 'admin.php?page=friends-settings&rerun-activate' ) ), 'friends-settings' ) ) + ) + ); + $result['description'] .= '

'; + } + + return $result; + } + public function site_status_test_php_modules( $modules ) { $modules['mbstring']['required'] = true; return $modules;