balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-redux-palette.php (2500B)


      1 <?php
      2 /**
      3  * Background Field.
      4  *
      5  * @package     ReduxFramework/Fields
      6  * @author      Kevin Provance (kprovance)
      7  * @version     4.0.0
      8  */
      9 
     10 defined( 'ABSPATH' ) || exit;
     11 
     12 if ( ! class_exists( 'Redux_Palette', false ) ) {
     13 
     14 	/**
     15 	 * Class Redux_Palette
     16 	 */
     17 	class Redux_Palette extends Redux_Field {
     18 
     19 		/**
     20 		 * Field Render Function.
     21 		 * Takes the vars and outputs the HTML for the field in the settingss
     22 		 *
     23 		 * @since       1.0.0
     24 		 * @access      public
     25 		 * @return      void
     26 		 */
     27 		public function render() {
     28 			if ( ! isset( $this->field['palettes'] ) && empty( $this->field['palettes'] ) ) {
     29 				echo 'No palettes have been set.';
     30 
     31 				return;
     32 			}
     33 
     34 			echo '<div id="' . esc_attr( $this->field['id'] ) . '" class="buttonset">';
     35 
     36 			foreach ( $this->field['palettes'] as $value => $color_set ) {
     37 				$checked = checked( $this->value, $value, false );
     38 
     39 				echo '<input
     40 						type="radio"
     41 						value="' . esc_attr( $value ) . '"
     42 						name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '"
     43 						class="redux-palette-set ' . esc_attr( $this->field['class'] ) . '"
     44 						id="' . esc_attr( $this->field['id'] . '-' . $value ) . '"' . esc_html( $checked ) . '>';
     45 
     46 				echo '<label for="' . esc_attr( $this->field['id'] . '-' . $value ) . '">';
     47 
     48 				foreach ( $color_set as $color ) {
     49 					echo '<span style=background:' . esc_attr( $color ) . '>' . esc_attr( $color ) . '</span>';
     50 				}
     51 
     52 				echo '</label>';
     53 				echo '</input>';
     54 			}
     55 
     56 			echo '</div>';
     57 		}
     58 
     59 		/**
     60 		 * Enqueue Function.
     61 		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
     62 		 *
     63 		 * @since       1.0.0
     64 		 * @access      public
     65 		 * @return      void
     66 		 */
     67 		public function enqueue() {
     68 			$min = Redux_Functions::is_min();
     69 
     70 			wp_enqueue_script(
     71 				'redux-field-palette-js',
     72 				Redux_Core::$url . 'inc/fields/palette/redux-palette' . $min . '.js',
     73 				array( 'jquery', 'redux-js', 'jquery-ui-button', 'jquery-ui-core' ),
     74 				$this->timestamp,
     75 				true
     76 			);
     77 
     78 			if ( $this->parent->args['dev_mode'] ) {
     79 				wp_enqueue_style(
     80 					'redux-field-palette-css',
     81 					Redux_Core::$url . 'inc/fields/palette/redux-palette.css',
     82 					array(),
     83 					$this->timestamp
     84 				);
     85 			}
     86 		}
     87 
     88 		/**
     89 		 * Enable output_variables to be generated.
     90 		 *
     91 		 * @since       4.0.3
     92 		 * @return void
     93 		 */
     94 		public function output_variables() {
     95 			// No code needed, just defining the method is enough.
     96 		}
     97 	}
     98 }
     99 
    100 class_alias( 'Redux_Palette', 'ReduxFramework_Palette' );