From fd6353505f6a8ed85e3180d8bbb3eff57bf2f0ef Mon Sep 17 00:00:00 2001 From: Gareth <5170216+gbissland@users.noreply.github.com> Date: Thu, 19 Dec 2024 07:24:37 +1300 Subject: [PATCH] Added color picker js --- generatepress-bb-color-palettes.php | 4 ++-- js/gp-color-picker.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 js/gp-color-picker.js diff --git a/generatepress-bb-color-palettes.php b/generatepress-bb-color-palettes.php index f54c9e6..50f0a3e 100644 --- a/generatepress-bb-color-palettes.php +++ b/generatepress-bb-color-palettes.php @@ -3,7 +3,7 @@ * Plugin Name: GeneratePress Global Colour Palette for Beaver Builder * Plugin URI: https://github.com/weavedigitalstudio/GeneratePress-BB-Color-Palettes * Description: A custom plugin to add Beaver Builder color picker compatibility for the GeneratePress Global Color Palette. - * Version: 0.2.5 + * Version: 0.2.6 * Primary Branch: main * GitHub Plugin URI: weavedigitalstudio/GeneratePress-BB-Color-Palettes * Author: Weave Digital Studio @@ -131,7 +131,7 @@ function( $color ) { 'generatepress-color-picker', plugin_dir_url( __FILE__ ) . 'js/gp-color-picker.js', [ 'wp-color-picker' ], - '0.2.4', // Use plugin version for cache busting + '0.2.6', // Use plugin version for cache busting true ); diff --git a/js/gp-color-picker.js b/js/gp-color-picker.js new file mode 100644 index 0000000..575ac60 --- /dev/null +++ b/js/gp-color-picker.js @@ -0,0 +1,20 @@ +(function($) { + // Ensure WordPress Iris exists + if (!$.a8c || !$.a8c.iris) { + return; + } + + // Extend Iris to set the GeneratePress palette globally + var originalCreate = $.a8c.iris.prototype._create; + $.a8c.iris.prototype._create = function() { + // Set the custom palette globally + if (typeof generatePressPalette !== 'undefined' && Array.isArray(generatePressPalette)) { + this.options.palettes = generatePressPalette; + } + + // Call the original Iris create function + originalCreate.call(this); + }; + + generatePressPalette); +})(jQuery);