Make WordPress Core

Changeset 44418


Ignore:
Timestamp:
01/07/2019 01:59:01 PM (6 years ago)
Author:
ocean90
Message:

I18n: Expose JSON translation file paths in load_script_textdomain().

Removes file_exist() checks before calling load_script_translations() to let the determined paths be passed to load_script_translations() which provides its own file check and the possibility to filter the path.

Props swissspidy, johnbillion, ocean90.
See #45769.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r44395 r44418  
    923923    $file_base       = $domain === 'default' ? $locale : $domain . '-' . $locale;
    924924    $handle_filename = $file_base . '-' . $handle . '.json';
    925     if ( $path && file_exists( $path . '/' . $handle_filename ) ) {
    926         return load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
     925
     926    if ( $path ) {
     927        $translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
     928
     929        if ( $translations ) {
     930            return $translations;
     931        }
    927932    }
    928933
     
    984989
    985990    $md5_filename = $file_base . '-' . md5( $relative ) . '.json';
    986     if ( $path && file_exists( $path . '/' . $md5_filename ) ) {
    987         return load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
    988     }
    989     if ( file_exists( $languages_path . '/' . $md5_filename ) ) {
    990         return load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
     991
     992    if ( $path ) {
     993        $translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
     994
     995        if ( $translations ) {
     996            return $translations;
     997        }
     998    }
     999
     1000    $translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
     1001
     1002    if ( $translations ) {
     1003        return $translations;
    9911004    }
    9921005
Note: See TracChangeset for help on using the changeset viewer.