From bd3fdcce0768e53a52c1331eb25c21a7926fbe82 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sat, 8 Feb 2025 15:58:11 +0000 Subject: [PATCH] General: Error messages improvements in `/wp-includes` files. This changeset improves a bunch of error messages, notably replacing the good old cryptic "Something went wrong" message with more helpful information. Props peterwilsoncc, netweb, karmatosed, JoshuaWold, mrtortai, audrasjb, sukhendu2002, joedolson. Fixes #43622. git-svn-id: https://develop.svn.wordpress.org/trunk@59790 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-customize-manager.php | 2 +- src/wp-includes/class-wp-xmlrpc-server.php | 6 +++--- src/wp-includes/functions.php | 2 +- src/wp-includes/script-loader.php | 4 ++-- src/wp-mail.php | 10 +++++++++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 8d5e94af94..51c88ef5fc 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -454,7 +454,7 @@ final class WP_Customize_Manager { } if ( ! $message ) { - $message = __( 'Something went wrong.' ); + $message = __( 'An error occurred while customizing. Please refresh the page and try again.' ); } if ( $this->messenger_channel ) { diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index e69d0eb395..c5a4eba66e 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -4031,7 +4031,7 @@ class wp_xmlrpc_server extends IXR_Server { } if ( ! $comment_id ) { - return new IXR_Error( 403, __( 'Something went wrong.' ) ); + return new IXR_Error( 403, __( 'An error occurred while processing your comment. Please ensure all fields are filled correctly and try again.' ) ); } /** @@ -5051,7 +5051,7 @@ class wp_xmlrpc_server extends IXR_Server { $posts_list = wp_get_recent_posts( $query ); if ( ! $posts_list ) { - $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); + $this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) ); return $this->error; } @@ -6584,7 +6584,7 @@ class wp_xmlrpc_server extends IXR_Server { $posts_list = wp_get_recent_posts( $query ); if ( ! $posts_list ) { - $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); + $this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) ); return $this->error; } diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index fd772424ab..fbad1f721a 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3672,7 +3672,7 @@ function get_allowed_mime_types( $user = null ) { */ function wp_nonce_ays( $action ) { // Default title and response code. - $title = __( 'Something went wrong.' ); + $title = __( 'An error occurred.' ); $response_code = 403; if ( 'log-out' === $action ) { diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 15ee7c6d25..aceeffcdc9 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -810,7 +810,7 @@ function wp_default_scripts( $scripts ) { 'wpAjax', array( 'noPerm' => __( 'Sorry, you are not allowed to do that.' ), - 'broken' => __( 'Something went wrong.' ), + 'broken' => __( 'An error occurred while processing your request. Please try again later.' ), ) ); @@ -1292,7 +1292,7 @@ function wp_default_scripts( $scripts ) { 'close' => __( 'Close' ), 'action' => __( 'Action' ), 'discardChanges' => __( 'Discard changes' ), - 'cheatin' => __( 'Something went wrong.' ), + 'cheatin' => __( 'An error occurred. Please try again later.' ), 'notAllowedHeading' => __( 'You need a higher level of permission.' ), 'notAllowed' => __( 'Sorry, you are not allowed to customize this site.' ), 'previewIframeTitle' => __( 'Site Preview' ), diff --git a/src/wp-mail.php b/src/wp-mail.php index 7b18dd4ad1..19c449b645 100644 --- a/src/wp-mail.php +++ b/src/wp-mail.php @@ -39,7 +39,15 @@ if ( ! defined( 'WP_MAIL_INTERVAL' ) ) { $last_checked = get_transient( 'mailserver_last_checked' ); if ( $last_checked ) { - wp_die( __( 'Slow down cowboy, no need to check for new mails so often!' ) ); + wp_die( + sprintf( + // translators: %s human readable rate limit. + __( 'Email checks are rate limited to once every %s.' ), + human_time_diff( time() - WP_MAIL_INTERVAL, time() ) + ), + __( 'Slow down, no need to check for new mails so often!' ), + 429 + ); } set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL );