From d772a0407e5b940291b659c77165b7c92607f325 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 17 Nov 2021 04:03:25 +0000 Subject: [PATCH] WPDB: Call `wp_load_translations_early()` in `wpdb::_real_escape()`. This follows the pattern used in other `wpdb` methods to make sure the i18n functions are available. Follow-up to [29840]. Props nacin, johnbillion. See #32315. git-svn-id: https://develop.svn.wordpress.org/trunk@52195 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 57c3bd76f6..0f54405185 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -1247,12 +1247,11 @@ class wpdb { } } else { $class = get_class( $this ); - if ( function_exists( '__' ) ) { - /* translators: %s: Database access abstraction class, usually wpdb or a class extending wpdb. */ - _doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' ); - } else { - _doing_it_wrong( $class, sprintf( '%s must set a database connection for use with escaping.', $class ), '3.6.0' ); - } + + wp_load_translations_early(); + /* translators: %s: Database access abstraction class, usually wpdb or a class extending wpdb. */ + _doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' ); + $escaped = addslashes( $string ); }