Last active
December 28, 2015 03:59
-
-
Save billerickson/7439188 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Register Latest Style | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/register-recent-style/ | |
*/ | |
function be_register_latest_style( $handle, $src, $deps, $ver, $media ) { | |
global $wp_styles; | |
if( !isset( $wp_styles->registered[$handle]->ver ) || version_compare( $ver, $wp_styles->registered[$handle]->ver ) ) { | |
wp_deregister_style( $handle ); | |
wp_register_style( $handle, $src, $deps, $ver, $media ); | |
} | |
} | |
// Example of Usage | |
function be_enqueue_styles() { | |
be_register_latest_style( 'genericons', get_stylesheet_directory_uri() . '/css/genericons/genericons.css', false, '3.0.2' ); | |
wp_enqueue_style( 'genericons' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'be_enqueue_styles' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment