Skip to content

Instantly share code, notes, and snippets.

@jg314
Last active December 10, 2015 20:38
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 jg314/4489182 to your computer and use it in GitHub Desktop.
Save jg314/4489182 to your computer and use it in GitHub Desktop.
<?php
function add_styles_scripts(){
//Access the global $wp_version variable to see which version of WordPress is installed.
global $wp_version;
//If the WordPress version is greater than or equal to 3.5, then load the new WordPress color picker.
if ( 3.5 <= $wp_version ){
//Both the necessary css and javascript have been registered already by WordPress, so all we have to do is load them with their handle.
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
}
//If the WordPress version is less than 3.5 load the older farbtasic color picker.
else {
//As with wp-color-picker the necessary css and javascript have been registered already by WordPress, so all we have to do is load them with their handle.
wp_enqueue_style( 'farbtastic' );
wp_enqueue_script( 'farbtastic' );
}
//Load our custom javascript file
wp_enqueue_script( 'wp-color-picker-settings', plugin_dir_url( __FILE__ ) . 'js/settings.js' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment