Skip to content

Commit

Permalink
Improve local path rewriting
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Feb 26, 2020
1 parent 376afed commit 2423a61
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/photon-cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ public static function fix_script_relative_path( $relative, $src ) {
}

/**
* Ensure use of the correct relative path when loading the JavaScript translation file.
* Ensure use of the correct local path when loading the JavaScript translation file for a CDN'ed asset.
*
* @param string $file The path that's going to be loaded.
* @param string $handle The script handle.
* @param string $domain The text domain.
* @return string The transformed local languages path.
*/
public static function fix_local_script_translation_path( $file, $handle, $domain ) {
switch ( $handle ) {
case 'jetpack-blocks-editor':
return str_replace( 'wp-content/languages/jetpack', 'wp-content/languages/plugins/jetpack', $file );
global $wp_scripts;
// This is a rewritten plugin URL, so load the language file from the plugins path.
if ( isset( $wp_scripts->registered[ $handle ] ) && wp_startswith( $wp_scripts->registered[ $handle ]->src, self::CDN . 'p' ) ) {
return WP_LANG_DIR . '/plugins/' . basename( $file );
}
return $file;
}
Expand Down

0 comments on commit 2423a61

Please sign in to comment.