Skip to content

Instantly share code, notes, and snippets.

@billerickson billerickson/functions.php
Last active Dec 28, 2015

Embed
What would you like to do?
<?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
You can’t perform that action at this time.