Skip to content

Commit

Permalink
Update enqueue-scripts.php to enqueue color picker script
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotts authored Sep 25, 2024
1 parent dd6df2d commit 0bf7596
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions includes/enqueue-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function vacw_enqueue_frontend_assets() {
}
add_action('wp_enqueue_scripts', 'vacw_enqueue_frontend_assets');

// Enqueue admin styles and scripts
// Enqueue admin styles and scripts, including the color picker for the settings page
function vacw_enqueue_admin_assets($hook) {
if ($hook != 'settings_page_vacw-settings') {
return;
Expand Down Expand Up @@ -86,5 +86,18 @@ function vacw_enqueue_admin_assets($hook) {
null,
true
);

// Enqueue the WordPress color picker script and style
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('wp-color-picker');

// Add a custom script to initialize the color picker
wp_enqueue_script(
'vacw-color-picker-script',
plugins_url('assets/admin-color-picker.js', __DIR__ . '/../'),
array('wp-color-picker'),
false,
true
);
}
add_action('admin_enqueue_scripts', 'vacw_enqueue_admin_assets');
add_action('admin_enqueue_scripts', 'vacw_enqueue_admin_assets');

0 comments on commit 0bf7596

Please sign in to comment.