Changeset 57516 for trunk/src/wp-includes/class-wp-textdomain-registry.php
- Timestamp:
- 02/01/2024 07:03:55 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-textdomain-registry.php
r57344 r57516 151 151 152 152 /** 153 * Retrieves .mofiles from the specified path.153 * Retrieves translation files from the specified path. 154 154 * 155 155 * Allows early retrieval through the {@see 'pre_get_mo_files_from_path'} filter to optimize … … 158 158 * @since 6.5.0 159 159 * 160 * @param string $path The directory path to search for .mofiles.161 * @return array Array of .mo file paths.160 * @param string $path The directory path to search for translation files. 161 * @return array Array of translation file paths. Can contain .mo and .l10n.php files. 162 162 */ 163 163 public function get_language_files_from_path( $path ) { … … 165 165 166 166 /** 167 * Filters the .mofiles retrieved from a specified path before the actual lookup.167 * Filters the translation files retrieved from a specified path before the actual lookup. 168 168 * 169 169 * Returning a non-null value from the filter will effectively short-circuit … … 175 175 * @since 6.5.0 176 176 * 177 * @param null|array $ mo_files List of .mofiles. Default null.178 * @param string $path The path from which .mofiles are being fetched.177 * @param null|array $files List of translation files. Default null. 178 * @param string $path The path from which translation files are being fetched. 179 179 **/ 180 $ mo_files = apply_filters( 'pre_get_language_files_from_path', null, $path );181 182 if ( null !== $ mo_files ) {183 return $ mo_files;180 $files = apply_filters( 'pre_get_language_files_from_path', null, $path ); 181 182 if ( null !== $files ) { 183 return $files; 184 184 } 185 185 186 186 $cache_key = 'cached_mo_files_' . md5( $path ); 187 $ mo_files= wp_cache_get( $cache_key, 'translations' );188 189 if ( false === $ mo_files ) {190 $ mo_files = glob( $path . '*.mo' );191 if ( false === $ mo_files ) {192 $ mo_files = array();187 $files = wp_cache_get( $cache_key, 'translations' ); 188 189 if ( false === $files ) { 190 $files = glob( $path . '*.mo' ); 191 if ( false === $files ) { 192 $files = array(); 193 193 } 194 wp_cache_set( $cache_key, $mo_files, 'translations' ); 195 } 196 197 return $mo_files; 194 195 $php_files = glob( $path . '*.l10n.php' ); 196 if ( is_array( $php_files ) ) { 197 $files = array_merge( $files, $php_files ); 198 } 199 200 wp_cache_set( $cache_key, $files, 'translations' ); 201 } 202 203 return $files; 198 204 } 199 205 … … 296 302 $files = $this->get_language_files_from_path( $location ); 297 303 298 $path = "$location/$domain-$locale.mo"; 299 300 foreach ( $files as $mo_path ) { 304 $mo_path = "$location/$domain-$locale.mo"; 305 $php_path = "$location/$domain-$locale.l10n.php"; 306 307 foreach ( $files as $file_path ) { 301 308 if ( 302 309 ! in_array( $domain, $this->domains_with_translations, true ) && 303 str_starts_with( str_replace( "$location/", '', $ mo_path ), "$domain-" )310 str_starts_with( str_replace( "$location/", '', $file_path ), "$domain-" ) 304 311 ) { 305 312 $this->domains_with_translations[] = $domain; 306 313 } 307 314 308 if ( $ mo_path === $path ) {315 if ( $file_path === $mo_path || $file_path === $php_path ) { 309 316 $found_location = rtrim( $location, '/' ) . '/'; 310 317 }
Note: See TracChangeset
for help on using the changeset viewer.