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/4489191 to your computer and use it in GitHub Desktop.
Save jg314/4489191 to your computer and use it in GitHub Desktop.
//Set up the color pickers to work with our text input field
jQuery( document ).ready(function(){
"use strict";
//This if statement checks if the color picker widget exists within jQuery UI
//If it does exist then we initialize the WordPress color picker on our text input field
if( typeof jQuery.wp === 'object' && typeof jQuery.wp.wpColorPicker === 'function' ){
jQuery( '#color' ).wpColorPicker();
}
else {
//We use farbtastic if the WordPress color picker widget doesn't exist
jQuery( '#colorpicker' ).farbtastic( '#color' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment