From 920f992ede76bc9b6e865b41660eb6da3a333145 Mon Sep 17 00:00:00 2001 From: Sky Shabatura Date: Fri, 17 Nov 2017 10:29:39 -0600 Subject: [PATCH 1/3] Adjusted control markup to work with WordPress 4.9. --- .../alpha-color-picker/alpha-color-picker.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/customizer/alpha-color-picker/alpha-color-picker.php b/customizer/alpha-color-picker/alpha-color-picker.php index 483d3f4..3eaf86d 100644 --- a/customizer/alpha-color-picker/alpha-color-picker.php +++ b/customizer/alpha-color-picker/alpha-color-picker.php @@ -70,24 +70,28 @@ public function render_content() { if ( is_array( $this->palette ) ) { $palette = implode( '|', $this->palette ); } else { - // Default to true. + // Default to true $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true'; } // Support passing show_opacity as string or boolean. Default to true. $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true'; - // Begin the output. ?> - + // Output the label if passed in + if ( isset( $this->label ) && '' !== $this->label ) { + echo '' . sanitize_text_field( $this->label ) . ''; + } + + // Output the description if passed in + if ( isset( $this->description ) && '' !== $this->description ) { + echo '' . sanitize_text_field( $this->description ) . ''; + } + ?> +
+ +
Date: Fri, 17 Nov 2017 10:30:36 -0600 Subject: [PATCH 2/3] Added filters for the script and style locations. --- customizer/alpha-color-picker/alpha-color-picker.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/customizer/alpha-color-picker/alpha-color-picker.php b/customizer/alpha-color-picker/alpha-color-picker.php index 3eaf86d..cc0a6dc 100644 --- a/customizer/alpha-color-picker/alpha-color-picker.php +++ b/customizer/alpha-color-picker/alpha-color-picker.php @@ -46,16 +46,22 @@ class Customize_Alpha_Color_Control extends WP_Customize_Control { * stand alone class we'll register and enqueue them here. */ public function enqueue() { + + $default_script_location = get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.js'; + wp_enqueue_script( 'alpha-color-picker', - get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.js', + apply_filters('alpha-color-picker-scripts', $default_script_location), array( 'jquery', 'wp-color-picker' ), '1.0.0', true ); + + $default_styles_location = get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.css'; + wp_enqueue_style( 'alpha-color-picker', - get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.css', + apply_filters('alpha-color-picker-styles', $default_styles_location), array( 'wp-color-picker' ), '1.0.0' ); From ddf44869854233c7f80796758b1f6b0d21e4e487 Mon Sep 17 00:00:00 2001 From: Ash <28295766+bluestockinger@users.noreply.github.com> Date: Tue, 4 Sep 2018 13:32:12 +1000 Subject: [PATCH 3/3] Changed enqueue method for script and style. Altering the enqueue method from `get_stylesheet_directory_uri` to `get_template_directory_uri` allows child themes to use the Alpha Color Picker. --- customizer/alpha-color-picker/alpha-color-picker.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/customizer/alpha-color-picker/alpha-color-picker.php b/customizer/alpha-color-picker/alpha-color-picker.php index cc0a6dc..eefceb1 100644 --- a/customizer/alpha-color-picker/alpha-color-picker.php +++ b/customizer/alpha-color-picker/alpha-color-picker.php @@ -47,7 +47,7 @@ class Customize_Alpha_Color_Control extends WP_Customize_Control { */ public function enqueue() { - $default_script_location = get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.js'; + $default_script_location = get_template_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.js'; wp_enqueue_script( 'alpha-color-picker', @@ -57,7 +57,7 @@ public function enqueue() { true ); - $default_styles_location = get_stylesheet_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.css'; + $default_styles_location = get_template_directory_uri() . '/admin/customizer/alpha-color-picker/alpha-color-picker.css'; wp_enqueue_style( 'alpha-color-picker', @@ -100,4 +100,4 @@ public function render_content() {