Changeset 49236 for trunk/src/wp-includes/deprecated.php
- Timestamp:
- 10/20/2020 04:03:58 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/deprecated.php
r49197 r49236 4135 4135 return is_string( $value ) ? addslashes( $value ) : $value; 4136 4136 } 4137 4138 /** 4139 * Gets the path to a translation file for loading a textdomain just in time. 4140 * 4141 * Caches the retrieved results internally. 4142 * 4143 * @since 4.7.0 4144 * @deprecated 5.6.0 4145 * @access private 4146 * 4147 * @see _load_textdomain_just_in_time() 4148 * 4149 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 4150 * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality. 4151 * @return string|false The path to the translation file or false if no translation file was found. 4152 */ 4153 function _get_path_to_translation( $domain, $reset = false ) { 4154 _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' ); 4155 4156 static $available_translations = array(); 4157 4158 if ( true === $reset ) { 4159 $available_translations = array(); 4160 } 4161 4162 if ( ! isset( $available_translations[ $domain ] ) ) { 4163 $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain ); 4164 } 4165 4166 return $available_translations[ $domain ]; 4167 } 4168 4169 /** 4170 * Gets the path to a translation file in the languages directory for the current locale. 4171 * 4172 * Holds a cached list of available .mo files to improve performance. 4173 * 4174 * @since 4.7.0 4175 * @deprecated 5.6.0 4176 * @access private 4177 * 4178 * @see _get_path_to_translation() 4179 * 4180 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 4181 * @return string|false The path to the translation file or false if no translation file was found. 4182 */ 4183 function _get_path_to_translation_from_lang_dir( $domain ) { 4184 _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' ); 4185 4186 static $cached_mofiles = null; 4187 4188 if ( null === $cached_mofiles ) { 4189 $cached_mofiles = array(); 4190 4191 $locations = array( 4192 WP_LANG_DIR . '/plugins', 4193 WP_LANG_DIR . '/themes', 4194 ); 4195 4196 foreach ( $locations as $location ) { 4197 $mofiles = glob( $location . '/*.mo' ); 4198 if ( $mofiles ) { 4199 $cached_mofiles = array_merge( $cached_mofiles, $mofiles ); 4200 } 4201 } 4202 } 4203 4204 $locale = determine_locale(); 4205 $mofile = "{$domain}-{$locale}.mo"; 4206 4207 $path = WP_LANG_DIR . '/plugins/' . $mofile; 4208 if ( in_array( $path, $cached_mofiles, true ) ) { 4209 return $path; 4210 } 4211 4212 $path = WP_LANG_DIR . '/themes/' . $mofile; 4213 if ( in_array( $path, $cached_mofiles, true ) ) { 4214 return $path; 4215 } 4216 4217 return false; 4218 }
Note: See TracChangeset
for help on using the changeset viewer.