. */ /** * Class Themeoo_Customize_Multi_Color_Control */ class Themeoo_Customize_Multi_Color_Control extends WP_Customize_Control { /** * Official control name. * * @var string */ public $type = 'multi-color'; /** * The array of color data. * * @var array */ public $color_data; /** * The label for this control group. * * @var string */ public $label; /** * Enqueue scripts and styles. * * Ideally these would get registered and given proper paths before this control object * gets initialized, then we could simply enqueue them here, but for completeness as a * stand alone class we'll register and enqueue them here. * * @return void */ public function enqueue() { wp_enqueue_script( 'multi-color-picker', get_stylesheet_directory_uri() . '/admin/customizer/multi-color-picker/multi-color-picker.js', array( 'jquery', 'wp-color-picker' ), '1.0.0', true ); wp_enqueue_style( 'multi-color-picker', get_stylesheet_directory_uri() . '/admin/customizer/multi-color-picker/multi-color-picker.css', array( 'wp-color-picker' ), '1.0.0' ); } /** * Render the control. * * @return void */ public function render_content() { if ( $this->label ) { echo '' . esc_html( $this->label ) . ''; } if ( $this->description ) { echo '' . wp_kses_post( $this->description ) . ''; } // Output the div that will wrap our picker triggers. echo '
'; // Loop over the color settings to output the actual inputs. foreach ( $this->settings as $key => $setting ) { // Store color data associated with the current setting. $color_data = $this->color_data[ $setting->id ]; // Process the palette. Default to 'true' if no palette was passed in. $palette = ( isset( $color_data['palette'] ) ) ? $color_data['palette'] : true; if ( is_array( $palette ) ) { $palette = implode( '|', $palette ); } elseif ( true === $palette || 'true' === $palette ) { $palette = 'true'; } else { $palette = 'false'; } // Grab the rest of the setting data. Define defaults to make everything except 'label' optional. $label = $color_data['label']; $default = ( isset( $color_data['default'] ) ) ? $color_data['default'] : '#000000'; $show_opacity = ( isset( $color_data['show_opacity'] ) ) ? $color_data['show_opacity'] : 'true'; ?> get_link( $key ) ); ?> />