This question here is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a response.
I am trying to implement the colour picker wheel as seen in the WordPress Theme Customization API pane for selecting colours. Loading the scripts and styles works fine when using the hook, “admin_enqueue_scripts” works however trying to load these scripts on the front-end using the hook, “wp_enqueue_scripts” does not work. The style gets enqueued, but not the script.
I want to avoid copying over files into my plugin duplicating what is already bundled with WordPress. There must be a way to get the Iris colour picker working on the front-end that I am not seeing.
And for those wondering why I want to do this, I am developing a plugin that adds a fly-out panel to the side of the screen which allows you to make realtime temporary styling changes to the site without having to login via the wp-admin panel.
This drove me mad for a while, but I got it to work by adding them with the full arguments that are used in the admin script loader rather than just referencing the handle. When I print the
$wp_scripts
global on the front end,iris
andwp-color-picker
are nowhere to be found, though all of their jQuery UI dependencies work. Anyway, not sure this is right, but it gets the job done:We need to wp_enqueue_script the script and wp_enqueue_style the style with add_action to the functions.php file. Just include a jQuery file and stylesheet file by this script.
Now create a new javascript file as like cp-active.js and keep it avobe defined â/js/cp-active.jsâ file path using bellows code.
Add a textbox to your settings page with a CSS class for the color picker, where you want to dispaly the input text. I have use âcolor_codeâ for input $variable.
Get details from here
I couldn’t make it work, so I used a simple HTML 5 color picker field instead.
<input type="color">