From afa2d8c796d6fe162e441b233915c33a3a151458 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Sun, 21 Jun 2020 10:09:29 -0600
Subject: [PATCH] Remove unnecessary check for `DISABLE_WP_CRON` being true
from `wp_get_auto_update_message()`.
Also changes all returned strings so they begin with `Automatic update...` and so the function has a single return.
---
src/wp-admin/includes/update.php | 44 +++++++++++++++-----------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php
index 29d5261212..469b383323 100644
|
a
|
b
|
function wp_get_auto_update_message() { |
| 984 | 984 | |
| 985 | 985 | // Check if event exists. |
| 986 | 986 | if ( false === $next_update_time ) { |
| 987 | | return __( 'There may be a problem with WP-Cron. Automatic update not scheduled.' ); |
| 988 | | } |
| 989 | | |
| 990 | | // See if cron is disabled |
| 991 | | $cron_disabled = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON; |
| 992 | | if ( $cron_disabled ) { |
| 993 | | return __( 'WP-Cron is disabled. Automatic updates not available.' ); |
| 994 | | } |
| 995 | | |
| 996 | | $time_to_next_update = human_time_diff( intval( $next_update_time ) ); |
| 997 | | |
| 998 | | // See if cron is overdue. |
| 999 | | $overdue = ( time() - $next_update_time ) > 0; |
| 1000 | | if ( $overdue ) { |
| 1001 | | return sprintf( |
| 1002 | | /* translators: Duration that WP-Cron has been overdue. */ |
| 1003 | | __( 'There may be a problem with WP-Cron. Automatic update overdue by %s.' ), |
| 1004 | | $time_to_next_update |
| 1005 | | ); |
| | 987 | $message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' ); |
| 1006 | 988 | } else { |
| 1007 | | return sprintf( |
| 1008 | | /* translators: Time until the next update. */ |
| 1009 | | __( 'Auto-update scheduled in %s.' ), |
| 1010 | | $time_to_next_update |
| 1011 | | ); |
| | 989 | $time_to_next_update = human_time_diff( intval( $next_update_time ) ); |
| | 990 | |
| | 991 | // See if cron is overdue. |
| | 992 | $overdue = ( time() - $next_update_time ) > 0; |
| | 993 | if ( $overdue ) { |
| | 994 | $message = sprintf( |
| | 995 | /* translators: Duration that WP-Cron has been overdue. */ |
| | 996 | __( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ), |
| | 997 | $time_to_next_update |
| | 998 | ); |
| | 999 | } else { |
| | 1000 | $message = sprintf( |
| | 1001 | /* translators: Time until the next update. */ |
| | 1002 | __( 'Automatic update scheduled in %s.' ), |
| | 1003 | $time_to_next_update |
| | 1004 | ); |
| | 1005 | } |
| 1012 | 1006 | } |
| | 1007 | |
| | 1008 | return $message; |
| 1013 | 1009 | } |