diff --git a/src/wp-includes/class-wp-locale-switcher.php b/src/wp-includes/class-wp-locale-switcher.php
index 8a9bbc3903..7ec7622161 100644
--- a/src/wp-includes/class-wp-locale-switcher.php
+++ b/src/wp-includes/class-wp-locale-switcher.php
@@ -196,12 +196,11 @@ class WP_Locale_Switcher {
load_default_textdomain( $locale );
foreach ( $domains as $domain ) {
- // The default text domain is handled by `load_default_textdomain()`.
if ( 'default' === $domain ) {
continue;
}
- unload_textdomain( $domain, true );
+ unload_textdomain( $domain );
get_translations_for_domain( $domain );
}
}
@@ -219,11 +218,12 @@ class WP_Locale_Switcher {
* @param string $locale The locale to change to.
*/
private function change_locale( $locale ) {
- global $wp_locale;
+ // Reset translation availability information.
+ _get_path_to_translation( null, true );
$this->load_translations( $locale );
- $wp_locale = new WP_Locale();
+ $GLOBALS['wp_locale'] = new WP_Locale();
/**
* Fires when the locale is switched to or restored.
diff --git a/src/wp-includes/class-wp-textdomain-registry.php b/src/wp-includes/class-wp-textdomain-registry.php
deleted file mode 100644
index 5a5da5ee9c..0000000000
--- a/src/wp-includes/class-wp-textdomain-registry.php
+++ /dev/null
@@ -1,130 +0,0 @@
-domains[ $domain ] ) ) {
- return $this->domains[ $domain ];
- }
-
- return $this->get_path_from_lang_dir( $domain );
- }
-
- /**
- * Sets the MO file path for a specific domain.
- *
- * @since 5.6.0
- *
- * @param string $domain Text domain.
- * @param string|false $path Language directory path or false if there is none available.
- */
- public function set( $domain, $path ) {
- $this->domains[ $domain ] = $path ? trailingslashit( $path ) : false;
- }
-
- /**
- * Resets the registry state.
- *
- * @since 5.6.0
- */
- public function reset() {
- $this->cached_mo_files = null;
- $this->domains = array();
- }
-
- /**
- * Gets the path to a translation file in the languages directory for the current locale.
- *
- * @since 5.6.0
- *
- * @param string $domain Text domain.
- * @return string|false MO file path or false if there is none available.
- */
- private function get_path_from_lang_dir( $domain ) {
- if ( null === $this->cached_mo_files ) {
- $this->cached_mo_files = array();
-
- $this->set_cached_mo_files();
- }
-
- $locale = determine_locale();
- $mofile = "{$domain}-{$locale}.mo";
-
- $path = WP_LANG_DIR . '/plugins/' . $mofile;
- if ( in_array( $path, $this->cached_mo_files, true ) ) {
- $path = WP_LANG_DIR . '/plugins/';
- $this->set( $domain, $path );
-
- return $path;
- }
-
- $path = WP_LANG_DIR . '/themes/' . $mofile;
- if ( in_array( $path, $this->cached_mo_files, true ) ) {
- $path = WP_LANG_DIR . '/themes/';
- $this->set( $domain, $path );
-
- return $path;
- }
-
- $this->set( $domain, false );
-
- return false;
- }
-
- /**
- * Reads and caches all available MO files from the plugins and themes language directories.
- *
- * @since 5.6.0
- */
- protected function set_cached_mo_files() {
- $locations = array(
- WP_LANG_DIR . '/plugins',
- WP_LANG_DIR . '/themes',
- );
-
- foreach ( $locations as $location ) {
- $mo_files = glob( $location . '/*.mo' );
-
- if ( $mo_files ) {
- $this->cached_mo_files = array_merge( $this->cached_mo_files, $mo_files );
- }
- }
- }
-}
diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php
index ca83d3dfb0..44999504dc 100644
--- a/src/wp-includes/deprecated.php
+++ b/src/wp-includes/deprecated.php
@@ -4134,85 +4134,3 @@ function wp_slash_strings_only( $value ) {
function addslashes_strings_only( $value ) {
return is_string( $value ) ? addslashes( $value ) : $value;
}
-
-/**
- * Gets the path to a translation file for loading a textdomain just in time.
- *
- * Caches the retrieved results internally.
- *
- * @since 4.7.0
- * @deprecated 5.6.0
- * @access private
- *
- * @see _load_textdomain_just_in_time()
- *
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality.
- * @return string|false The path to the translation file or false if no translation file was found.
- */
-function _get_path_to_translation( $domain, $reset = false ) {
- _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' );
-
- static $available_translations = array();
-
- if ( true === $reset ) {
- $available_translations = array();
- }
-
- if ( ! isset( $available_translations[ $domain ] ) ) {
- $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain );
- }
-
- return $available_translations[ $domain ];
-}
-
-/**
- * Gets the path to a translation file in the languages directory for the current locale.
- *
- * Holds a cached list of available .mo files to improve performance.
- *
- * @since 4.7.0
- * @deprecated 5.6.0
- * @access private
- *
- * @see _get_path_to_translation()
- *
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- * @return string|false The path to the translation file or false if no translation file was found.
- */
-function _get_path_to_translation_from_lang_dir( $domain ) {
- _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' );
-
- static $cached_mofiles = null;
-
- if ( null === $cached_mofiles ) {
- $cached_mofiles = array();
-
- $locations = array(
- WP_LANG_DIR . '/plugins',
- WP_LANG_DIR . '/themes',
- );
-
- foreach ( $locations as $location ) {
- $mofiles = glob( $location . '/*.mo' );
- if ( $mofiles ) {
- $cached_mofiles = array_merge( $cached_mofiles, $mofiles );
- }
- }
- }
-
- $locale = determine_locale();
- $mofile = "{$domain}-{$locale}.mo";
-
- $path = WP_LANG_DIR . '/plugins/' . $mofile;
- if ( in_array( $path, $cached_mofiles, true ) ) {
- return $path;
- }
-
- $path = WP_LANG_DIR . '/themes/' . $mofile;
- if ( in_array( $path, $cached_mofiles, true ) ) {
- return $path;
- }
-
- return false;
-}
diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php
index 6bca550e98..0c6b75ea24 100644
--- a/src/wp-includes/l10n.php
+++ b/src/wp-includes/l10n.php
@@ -689,16 +689,15 @@ function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' )
*
* @since 1.5.0
*
- * @global MO[] $l10n An array of all currently loaded text domains.
- * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
- * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
+ * @global MO[] $l10n An array of all currently loaded text domains.
+ * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mofile Path to the .mo file.
* @return bool True on success, false on failure.
*/
function load_textdomain( $domain, $mofile ) {
- global $l10n, $l10n_unloaded, $wp_textdomain_registry;
+ global $l10n, $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
@@ -756,9 +755,6 @@ function load_textdomain( $domain, $mofile ) {
$l10n[ $domain ] = &$mo;
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- $wp_textdomain_registry->set( $domain, dirname( $mofile ) );
-
return true;
}
@@ -766,16 +762,14 @@ function load_textdomain( $domain, $mofile ) {
* Unload translations for a text domain.
*
* @since 3.0.0
- * @since 5.6.0 Added the `$reloadable` parameter.
*
* @global MO[] $l10n An array of all currently loaded text domains.
* @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
*
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- * @param bool $reloadable Whether the text domain can be loaded just-in-time again.
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool Whether textdomain was unloaded.
*/
-function unload_textdomain( $domain, $reloadable = false ) {
+function unload_textdomain( $domain ) {
global $l10n, $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
@@ -784,18 +778,14 @@ function unload_textdomain( $domain, $reloadable = false ) {
* Filters whether to override the text domain unloading.
*
* @since 3.0.0
- * @since 5.6.0 Added the `$reloadable` parameter.
*
- * @param bool $override Whether to override the text domain unloading. Default false.
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- * @param bool $reloadable Whether the text domain can be loaded just-in-time again.
+ * @param bool $override Whether to override the text domain unloading. Default false.
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
- $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain, $reloadable );
+ $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
if ( $plugin_override ) {
- if ( ! $reloadable ) {
- $l10n_unloaded[ $domain ] = true;
- }
+ $l10n_unloaded[ $domain ] = true;
return true;
}
@@ -804,19 +794,15 @@ function unload_textdomain( $domain, $reloadable = false ) {
* Fires before the text domain is unloaded.
*
* @since 3.0.0
- * @since 5.6.0 Added the `$reloadable` parameter.
*
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- * @param bool $reloadable Whether the text domain can be loaded just-in-time again.
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
- do_action( 'unload_textdomain', $domain, $reloadable );
+ do_action( 'unload_textdomain', $domain );
if ( isset( $l10n[ $domain ] ) ) {
unset( $l10n[ $domain ] );
- if ( ! $reloadable ) {
- $l10n_unloaded[ $domain ] = true;
- }
+ $l10n_unloaded[ $domain ] = true;
return true;
}
@@ -881,8 +867,6 @@ function load_default_textdomain( $locale = null ) {
* @return bool True when textdomain is successfully loaded, false otherwise.
*/
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
- global $wp_textdomain_registry;
-
/**
* Filters a plugin's locale.
*
@@ -909,9 +893,6 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
$path = WP_PLUGIN_DIR;
}
- /* @var WP_Textdomain_Registry $wp_textdomain_registry */
- $wp_textdomain_registry->set( $domain, $path );
-
return load_textdomain( $domain, $path . '/' . $mofile );
}
@@ -921,16 +902,12 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
* @since 3.0.0
* @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
*
- * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
- *
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
* file resides. Default empty string.
* @return bool True when textdomain is successfully loaded, false otherwise.
*/
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
- global $wp_textdomain_registry;
-
/** This filter is documented in wp-includes/l10n.php */
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
@@ -943,9 +920,6 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
- /* @var WP_Textdomain_Registry $wp_textdomain_registry */
- $wp_textdomain_registry->set( $domain, $path );
-
return load_textdomain( $domain, $path . '/' . $mofile );
}
@@ -960,16 +934,12 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
* @since 1.5.0
* @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
*
- * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
- *
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $path Optional. Path to the directory containing the .mo file.
* Default false.
* @return bool True when textdomain is successfully loaded, false otherwise.
*/
function load_theme_textdomain( $domain, $path = false ) {
- global $wp_textdomain_registry;
-
/**
* Filters a theme's locale.
*
@@ -991,9 +961,6 @@ function load_theme_textdomain( $domain, $path = false ) {
$path = get_template_directory();
}
- /* @var WP_Textdomain_Registry $wp_textdomain_registry */
- $wp_textdomain_registry->set( $domain, $path );
-
return load_textdomain( $domain, $path . '/' . $locale . '.mo' );
}
@@ -1223,14 +1190,14 @@ function load_script_translations( $file, $handle, $domain ) {
* @since 4.6.0
* @access private
*
- * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
- * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
+ * @see get_translations_for_domain()
+ * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool True when the textdomain is successfully loaded, false otherwise.
*/
function _load_textdomain_just_in_time( $domain ) {
- global $l10n_unloaded, $wp_textdomain_registry;
+ global $l10n_unloaded;
$l10n_unloaded = (array) $l10n_unloaded;
@@ -1239,24 +1206,88 @@ function _load_textdomain_just_in_time( $domain ) {
return false;
}
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- $path = $wp_textdomain_registry->get( $domain );
- if ( ! $path ) {
+ $translation_path = _get_path_to_translation( $domain );
+ if ( false === $translation_path ) {
return false;
}
- $locale = determine_locale();
+ return load_textdomain( $domain, $translation_path );
+}
- // Themes with their language directory outside of WP_LANG_DIR have a different file name.
- $template_directory = trailingslashit( get_template_directory() );
- $stylesheet_directory = trailingslashit( get_stylesheet_directory() );
- if ( 0 === strpos( $path, $template_directory ) || 0 === strpos( $path, $stylesheet_directory ) ) {
- $mofile = "{$path}{$locale}.mo";
- } else {
- $mofile = "{$path}{$domain}-{$locale}.mo";
+/**
+ * Gets the path to a translation file for loading a textdomain just in time.
+ *
+ * Caches the retrieved results internally.
+ *
+ * @since 4.7.0
+ * @access private
+ *
+ * @see _load_textdomain_just_in_time()
+ *
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
+ * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality.
+ * @return string|false The path to the translation file or false if no translation file was found.
+ */
+function _get_path_to_translation( $domain, $reset = false ) {
+ static $available_translations = array();
+
+ if ( true === $reset ) {
+ $available_translations = array();
}
- return load_textdomain( $domain, $mofile );
+ if ( ! isset( $available_translations[ $domain ] ) ) {
+ $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain );
+ }
+
+ return $available_translations[ $domain ];
+}
+
+/**
+ * Gets the path to a translation file in the languages directory for the current locale.
+ *
+ * Holds a cached list of available .mo files to improve performance.
+ *
+ * @since 4.7.0
+ * @access private
+ *
+ * @see _get_path_to_translation()
+ *
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
+ * @return string|false The path to the translation file or false if no translation file was found.
+ */
+function _get_path_to_translation_from_lang_dir( $domain ) {
+ static $cached_mofiles = null;
+
+ if ( null === $cached_mofiles ) {
+ $cached_mofiles = array();
+
+ $locations = array(
+ WP_LANG_DIR . '/plugins',
+ WP_LANG_DIR . '/themes',
+ );
+
+ foreach ( $locations as $location ) {
+ $mofiles = glob( $location . '/*.mo' );
+ if ( $mofiles ) {
+ $cached_mofiles = array_merge( $cached_mofiles, $mofiles );
+ }
+ }
+ }
+
+ $locale = determine_locale();
+ $mofile = "{$domain}-{$locale}.mo";
+
+ $path = WP_LANG_DIR . '/plugins/' . $mofile;
+ if ( in_array( $path, $cached_mofiles, true ) ) {
+ return $path;
+ }
+
+ $path = WP_LANG_DIR . '/themes/' . $mofile;
+ if ( in_array( $path, $cached_mofiles, true ) ) {
+ return $path;
+ }
+
+ return false;
}
/**
@@ -1266,7 +1297,7 @@ function _load_textdomain_just_in_time( $domain ) {
*
* @since 2.8.0
*
- * @global MO[] $l10n An array of all currently loaded text domains.
+ * @global MO[] $l10n
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return Translations|NOOP_Translations A Translations instance.
@@ -1290,7 +1321,7 @@ function get_translations_for_domain( $domain ) {
*
* @since 3.0.0
*
- * @global MO[] $l10n An array of all currently loaded text domains.
+ * @global MO[] $l10n
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool Whether there are translations.
diff --git a/src/wp-settings.php b/src/wp-settings.php
index 9f1f24beb0..71868ecc89 100644
--- a/src/wp-settings.php
+++ b/src/wp-settings.php
@@ -152,7 +152,6 @@ if ( SHORTINIT ) {
// Load the L10n library.
require_once ABSPATH . WPINC . '/l10n.php';
-require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php';
require_once ABSPATH . WPINC . '/class-wp-locale.php';
require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php';
@@ -302,17 +301,6 @@ require ABSPATH . WPINC . '/block-supports/typography.php';
$GLOBALS['wp_embed'] = new WP_Embed();
-/**
- * WordPress Textdomain Registry object.
- *
- * Used to support just-in-time translations for manually loaded textdomains.
- *
- * @since 5.6.0
- *
- * @global WP_Locale_Switcher $wp_locale_switcher WordPress Textdomain Registry.
- */
-$GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry();
-
// Load multisite-specific files.
if ( is_multisite() ) {
require ABSPATH . WPINC . '/ms-functions.php';
diff --git a/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.mo b/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.mo
index 08ee966a8a..96bf7ad890 100644
Binary files a/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.mo and b/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.mo differ
diff --git a/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.po b/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.po
index b784913576..bfb7d8ca39 100644
--- a/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.po
+++ b/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.po
@@ -2,20 +2,18 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:31+0100\n"
-"PO-Revision-Date: 2020-10-20 17:11+0200\n"
+"PO-Revision-Date: 2016-10-26 00:02+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 2.4.1\n"
+"X-Generator: Poedit 1.8.10\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
-"Language-Team: \n"
-"Last-Translator: \n"
"X-Poedit-SearchPath-0: .\n"
#: internationalized-plugin.php:11
diff --git a/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.mo b/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.mo
deleted file mode 100644
index 026af5850e..0000000000
Binary files a/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.mo and /dev/null differ
diff --git a/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.po b/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.po
deleted file mode 100644
index 788036ab12..0000000000
--- a/tests/phpunit/data/languages/plugins/internationalized-plugin-es_ES.po
+++ /dev/null
@@ -1,23 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: \n"
-"POT-Creation-Date: 2015-12-31 16:31+0100\n"
-"PO-Revision-Date: 2020-10-20 17:12+0200\n"
-"Language: de_DE\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 2.4.1\n"
-"X-Poedit-Basepath: .\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
-"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
-"esc_html_x:1,2c\n"
-"X-Textdomain-Support: yes\n"
-"Language-Team: \n"
-"Last-Translator: \n"
-"X-Poedit-SearchPath-0: .\n"
-
-#: internationalized-plugin.php:11
-msgid "This is a dummy plugin"
-msgstr "Este es un plugin dummy"
diff --git a/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.mo b/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.mo
index a48788607d..5a95f01bab 100644
Binary files a/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.mo and b/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.mo differ
diff --git a/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.po b/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.po
index 03ed5de8c6..6d2391756f 100644
--- a/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.po
+++ b/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.po
@@ -2,20 +2,18 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:38+0100\n"
-"PO-Revision-Date: 2020-10-20 17:09+0200\n"
+"PO-Revision-Date: 2016-10-26 00:02+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 2.4.1\n"
+"X-Generator: Poedit 1.8.10\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
-"Last-Translator: \n"
-"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:7
diff --git a/tests/phpunit/data/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php b/tests/phpunit/data/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php
deleted file mode 100644
index 41eb593556..0000000000
--- a/tests/phpunit/data/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php
+++ /dev/null
@@ -1,14 +0,0 @@
-Hello, Dolly in the upper right of your admin screen on every page.
Author: Matt Mullenweg
-Version: 1.7.2
+Version: 1.5.1
Author URI: http://ma.tt/
Text Domain: hello-dolly
*/
+
+// Test for
+?>
diff --git a/tests/phpunit/data/themedir1/custom-internationalized-theme/functions.php b/tests/phpunit/data/themedir1/custom-internationalized-theme/functions.php
deleted file mode 100644
index 272deed498..0000000000
--- a/tests/phpunit/data/themedir1/custom-internationalized-theme/functions.php
+++ /dev/null
@@ -1,10 +0,0 @@
-=' ) ) {
@@ -53,23 +48,8 @@ if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpuni
exit( 1 );
}
-$required_extensions = array(
- 'gd',
-);
-$missing_extensions = array();
-
-foreach ( $required_extensions as $extension ) {
- if ( ! extension_loaded( $extension ) ) {
- $missing_extensions[] = $extension;
- }
-}
-
-if ( $missing_extensions ) {
- printf(
- "Error: The following required PHP extensions are missing from the testing environment: %s.\n",
- implode( ', ', $missing_extensions )
- );
- echo "Please make sure they are installed and enabled.\n",
+if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
+ echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
exit( 1 );
}
@@ -79,34 +59,24 @@ $required_constants = array(
'WP_TESTS_TITLE',
'WP_PHP_BINARY',
);
-$missing_constants = array();
foreach ( $required_constants as $constant ) {
if ( ! defined( $constant ) ) {
- $missing_constants[] = $constant;
+ printf(
+ "Error: The required %s constant is not defined. Check out `wp-tests-config-sample.php` for an example.\n",
+ $constant
+ );
+ exit( 1 );
}
}
-if ( $missing_constants ) {
- printf(
- "Error: The following required constants are not defined: %s.\n",
- implode( ', ', $missing_constants )
- );
- echo "Please check out `wp-tests-config-sample.php` for an example.\n",
- exit( 1 );
-}
-
tests_reset__SERVER();
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
define( 'DIR_TESTDATA', __DIR__ . '/../data' );
define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
-define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
-
-if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
- define( 'WP_PLUGIN_DIR', realpath( DIR_TESTDATA . '/plugins' ) );
-}
+define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) {
define( 'WP_TESTS_FORCE_KNOWN_BUGS', false );
@@ -170,10 +140,6 @@ $GLOBALS['_wp_die_disabled'] = false;
tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
// Use the Spy REST Server instead of default.
tests_add_filter( 'wp_rest_server_class', '_wp_rest_server_class_filter' );
-// Prevent updating translations asynchronously.
-tests_add_filter( 'async_update_translation', '__return_false' );
-// Disable background updates.
-tests_add_filter( 'automatic_updater_disabled', '__return_true' );
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as other settings.
diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php
index 90bc2c3aa2..d880e240c9 100644
--- a/tests/phpunit/tests/admin/includesPlugin.php
+++ b/tests/phpunit/tests/admin/includesPlugin.php
@@ -14,7 +14,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. By Matt Mullenweg.',
'Author' => 'Matt Mullenweg',
'AuthorURI' => 'http://ma.tt/',
- 'Version' => '1.7.2',
+ 'Version' => '1.5.1',
'TextDomain' => 'hello-dolly',
'DomainPath' => '',
);
diff --git a/tests/phpunit/tests/l10n/loadTextdomain.php b/tests/phpunit/tests/l10n/loadTextdomain.php
index 8d2d474567..b905ceb036 100644
--- a/tests/phpunit/tests/l10n/loadTextdomain.php
+++ b/tests/phpunit/tests/l10n/loadTextdomain.php
@@ -24,22 +24,12 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
add_filter( 'plugin_locale', array( $this, 'store_locale' ) );
add_filter( 'theme_locale', array( $this, 'store_locale' ) );
-
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
}
public function tearDown() {
remove_filter( 'plugin_locale', array( $this, 'store_locale' ) );
remove_filter( 'theme_locale', array( $this, 'store_locale' ) );
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
-
parent::tearDown();
}
@@ -126,13 +116,13 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
/**
* @ticket 21319
*/
- public function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
+ function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
__( 'just some string', 'wp-tests-domain' );
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
}
- public function test_override_load_textdomain_noop() {
+ function test_override_load_textdomain_noop() {
add_filter( 'override_load_textdomain', '__return_true' );
$load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
remove_filter( 'override_load_textdomain', '__return_true' );
@@ -141,7 +131,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
}
- public function test_override_load_textdomain_non_existent_mofile() {
+ function test_override_load_textdomain_non_existent_mofile() {
add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' );
remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) );
@@ -155,7 +145,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
$this->assertFalse( $is_textdomain_loaded_after );
}
- public function test_override_load_textdomain_custom_mofile() {
+ function test_override_load_textdomain_custom_mofile() {
add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' );
remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) );
@@ -175,7 +165,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
* @param string $file Path to the MO file.
* @return bool
*/
- public function _override_load_textdomain_filter( $override, $domain, $file ) {
+ function _override_load_textdomain_filter( $override, $domain, $file ) {
global $l10n;
if ( ! is_readable( $file ) ) {
diff --git a/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php b/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
index 25b6ac3771..e0aa3df644 100644
--- a/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
+++ b/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
@@ -32,12 +32,10 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
add_filter( 'template_root', array( $this, 'filter_theme_root' ) );
wp_clean_themes_cache();
- unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
-
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
+ unset( $GLOBALS['wp_themes'] );
+ unset( $GLOBALS['l10n'] );
+ unset( $GLOBALS['l10n_unloaded'] );
+ _get_path_to_translation( null, true );
}
public function tearDown() {
@@ -46,12 +44,10 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
remove_filter( 'template_root', array( $this, 'filter_theme_root' ) );
wp_clean_themes_cache();
- unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
-
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
+ unset( $GLOBALS['wp_themes'] );
+ unset( $GLOBALS['l10n'] );
+ unset( $GLOBALS['l10n_unloaded'] );
+ _get_path_to_translation( null, true );
parent::tearDown();
}
@@ -174,7 +170,6 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
/**
* @ticket 37997
- * @ticket 39210
*/
public function test_plugin_translation_after_switching_locale_twice() {
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
@@ -188,7 +183,7 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
restore_current_locale();
$this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_de );
- $this->assertSame( 'Este es un plugin dummy', $expected_es_es );
+ $this->assertSame( 'This is a dummy plugin', $expected_es_es );
}
/**
diff --git a/tests/phpunit/tests/l10n/localeSwitcher.php b/tests/phpunit/tests/l10n/localeSwitcher.php
index 62c4ae4bd3..ec86fcbca4 100644
--- a/tests/phpunit/tests/l10n/localeSwitcher.php
+++ b/tests/phpunit/tests/l10n/localeSwitcher.php
@@ -22,21 +22,15 @@ class Tests_Locale_Switcher extends WP_UnitTestCase {
$this->locale = '';
$this->previous_locale = '';
- unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
-
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
+ unset( $GLOBALS['l10n'] );
+ unset( $GLOBALS['l10n_unloaded'] );
+ _get_path_to_translation( null, true );
}
public function tearDown() {
- unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
-
- /** @var WP_Textdomain_Registry $wp_textdomain_registry */
- global $wp_textdomain_registry;
-
- $wp_textdomain_registry->reset();
+ unset( $GLOBALS['l10n'] );
+ unset( $GLOBALS['l10n_unloaded'] );
+ _get_path_to_translation( null, true );
parent::tearDown();
}
@@ -394,77 +388,6 @@ class Tests_Locale_Switcher extends WP_UnitTestCase {
$this->assertSame( 'This is a dummy plugin', $expected );
}
- /**
- * @ticket 39210
- */
- public function test_switch_reloads_plugin_translations_outside_wp_lang_dir() {
- global $wp_locale_switcher, $wp_textdomain_registry;
-
- $locale_switcher = clone $wp_locale_switcher;
-
- $wp_locale_switcher = new WP_Locale_Switcher();
- $wp_locale_switcher->init();
-
- require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
-
- $this->assertSame( WP_PLUGIN_DIR . '/custom-internationalized-plugin/languages/', $wp_textdomain_registry->get( 'custom-internationalized-plugin' ) );
-
- $expected = custom_i18n_plugin_test();
- $this->assertSame( 'This is a dummy plugin', $expected );
-
- switch_to_locale( 'es_ES' );
- switch_to_locale( 'de_DE' );
-
- $expected = custom_i18n_plugin_test();
- $this->assertSame( 'Das ist ein Dummy Plugin', $expected );
-
- restore_previous_locale();
-
- $expected = custom_i18n_plugin_test();
- $this->assertSame( 'Este es un plugin dummy', $expected );
-
- restore_current_locale();
-
- $wp_locale_switcher = $locale_switcher;
- }
-
- /**
- * @ticket 39210
- */
- public function test_switch_reloads_theme_translations_outside_wp_lang_dir() {
- global $wp_locale_switcher, $wp_textdomain_registry;
-
- $locale_switcher = clone $wp_locale_switcher;
-
- $wp_locale_switcher = new WP_Locale_Switcher();
- $wp_locale_switcher->init();
-
- switch_theme( 'custom-internationalized-theme' );
-
- require_once get_stylesheet_directory() . '/functions.php';
-
- $this->assertSame( get_template_directory() . '/languages/', $wp_textdomain_registry->get( 'custom-internationalized-theme' ) );
-
- $expected = custom_i18n_theme_test();
-
- $this->assertSame( 'This is a dummy theme', $expected );
-
- switch_to_locale( 'es_ES' );
- switch_to_locale( 'de_DE' );
-
- $expected = custom_i18n_theme_test();
- $this->assertSame( 'Das ist ein Dummy Theme', $expected );
-
- restore_previous_locale();
-
- $expected = custom_i18n_theme_test();
- $this->assertSame( 'Este es un tema dummy', $expected );
-
- restore_current_locale();
-
- $wp_locale_switcher = $locale_switcher;
- }
-
public function filter_locale() {
return 'es_ES';
}
diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php
index f34fe53d2d..ae02c39008 100644
--- a/tests/phpunit/tests/theme/themeDir.php
+++ b/tests/phpunit/tests/theme/themeDir.php
@@ -162,7 +162,6 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
'Page Template Theme', // Theme with page templates for other test code.
'Theme with Spaces in the Directory',
'Internationalized Theme',
- 'Custom Internationalized Theme',
'camelCase',
'REST Theme',
);