Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset CDN: Fix json translation loading #10982

Merged
merged 4 commits into from
Dec 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions modules/photon-cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function go() {
add_action( 'admin_print_scripts', array( __CLASS__, 'cdnize_assets' ) );
add_action( 'admin_print_styles', array( __CLASS__, 'cdnize_assets' ) );
add_action( 'wp_footer', array( __CLASS__, 'cdnize_assets' ) );
add_filter( 'load_script_textdomain_relative_path', array( __CLASS__, 'fix_script_relative_path' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -83,6 +84,17 @@ public static function cdnize_assets() {
}
}

/**
* Ensure use of the correct relative path when determining the JavaScript file names.
*
* @param string $relative The relative path of the script. False if it could not be determined.
* @param string $src The full source url of the script.
* @return string The expected relative path for the CDN-ed URL.
*/
public static function fix_script_relative_path( $relative, $src ) {
return substr( $src, 1 + strpos( $src, '/wp-includes/' ) );
}

/**
* Sets up CDN URLs for supported plugin assets.
*
Expand Down