WordPress.org

Make WordPress Core

Changeset 44419


Ignore:
Timestamp:
01/07/2019 02:41:53 PM (11 months 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.

Merge of [44418] to the 5.0 branch.

Props swissspidy, johnbillion, ocean90.
Fixes #45769.

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

  • branches/5.0/src/wp-includes/l10n.php

    r44288 r44419  
    898898    $file_base       = $domain === 'default' ? $locale : $domain . '-' . $locale;
    899899    $handle_filename = $file_base . '-' . $handle . '.json';
    900     if ( $path && file_exists( $path . '/' . $handle_filename ) ) {
    901         return load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
     900
     901    if ( $path ) {
     902        $translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
     903
     904        if ( $translations ) {
     905            return $translations;
     906        }
    902907    }
    903908
     
    959964
    960965    $md5_filename = $file_base . '-' . md5( $relative ) . '.json';
    961     if ( $path && file_exists( $path . '/' . $md5_filename ) ) {
    962         return load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
    963     }
    964     if ( file_exists( $languages_path . '/' . $md5_filename ) ) {
    965         return load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
     966
     967    if ( $path ) {
     968        $translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
     969
     970        if ( $translations ) {
     971            return $translations;
     972        }
     973    }
     974
     975    $translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
     976
     977    if ( $translations ) {
     978        return $translations;
    966979    }
    967980
Note: See TracChangeset for help on using the changeset viewer.