Last active
October 20, 2017 03:25
-
-
Save jhayiwg/92bae4330aeb738a98022d7ab63ce9b1 to your computer and use it in GitHub Desktop.
Development Mode ( Ignore Caching in Dev mode )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/ * | |
* Development Mode ( Ignore Caching for Dev mode ) | |
* | |
* This snippet generate version for all theme css and js to load the actual code when you are in development mode | |
* Instruction | |
* *Add this to your active theme functions.php | |
* * Add define( 'WP_ENV', 'local' ); to your wp-config.php | |
* * from your production server make sure you remove the defined WP_ENV or set the value to 'production' | |
*/ | |
add_filter( 'script_loader_src', 'wpe_style_script_loader_src', 9999 ); | |
add_filter( 'style_loader_src', 'wpe_style_script_loader_src', 9999 ); | |
function wpe_style_script_loader_src( $src ) { | |
if( ! defined( "WP_ENV" ) || ( defined( "WP_ENV" ) && WP_ENV == 'production' ) ) return $src; | |
if( strpos ( $src, get_stylesheet_directory_uri() ) !== false ) | |
$src = add_query_arg('ver', time(), $src); | |
return $src; | |
} | |
add_action( 'login_enqueue_scripts', 'wpe_login_stylesheet' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment