WP_REST_Site_Health_Controller::load_admin_textdomain() WordPress Method

The WP_REST_Site_Health_Controller::load_admin_textdomain() method is used to load the translation files for the WordPress admin interface. This is necessary for any site that is running in a language other than English. The method takes two parameters: the domain and the path to the translation files. The domain is the unique identifier for the translation files. The path is the location of the translation files. The method returns true if the translation files are successfully loaded. Otherwise, it returns false.

WP_REST_Site_Health_Controller::load_admin_textdomain() #

Loads the admin textdomain for Site Health tests.


Description

The WP_Site_Health class is defined in WP-Admin, while the REST API operates in a front-end context. This means that the translations for Site Health won’t be loaded by default in load_default_textdomain().


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php

	protected function load_admin_textdomain() {
		// Accounts for inner REST API requests in the admin.
		if ( ! is_admin() ) {
			$locale = determine_locale();
			load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.