Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active December 28, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/7439188 to your computer and use it in GitHub Desktop.
Save billerickson/7439188 to your computer and use it in GitHub Desktop.
<?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