Skip to content

Commit

Permalink
Change the default version of dependencies
Browse files Browse the repository at this point in the history
By default, all dependencies without defined version use
the WP one instead.
It's not a bad idea but as it's a good practice to hide the WP version,
it becomes a "security issue". To be sure to don't find WP version
into dependency URLs, we modify default dependency version at the source
to be sure to impact a maximum of cases
(e.g.: `_print_styles` from `wp-login.php`).
  • Loading branch information
7studio committed Mar 8, 2017
1 parent 60a68fa commit 601cb1b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@ function thistle_enqueue_assets() {
}
add_action( 'wp_enqueue_scripts', 'thistle_enqueue_assets' );

if ( ! function_exists( 'thistle_change_dependencies_default_version' ) ) {
/**
* Transforms the default version of dependencies to hide the WP version in URLs.
*
* @param WP_Styles|WP_Scripts $dependencies WP_Dependencies instance, passed by reference.
*/
function thistle_change_dependencies_default_version( $dependencies ) {
if ( ! is_admin() ) {
$dependencies->default_version = md5( ABSPATH . '/wp-version/' . $dependencies->default_version );
}
}
}
add_action( 'wp_default_styles', 'thistle_change_dependencies_default_version', PHP_INT_MAX );
add_action( 'wp_default_scripts', 'thistle_change_dependencies_default_version', PHP_INT_MAX );



require_once THISTLE_PATH . '/includes/attachment.php';
Expand Down

0 comments on commit 601cb1b

Please sign in to comment.