ReduxFramework_palette

The evolve ReduxFramework palette class.

Defined (1)

The class is defined in the following location(s).

/library/admin/redux-framework/inc/fields/palette/field_palette.php  
  1. class ReduxFramework_palette { 
  2.  
  3. /** 
  4. * Field Constructor. 
  5. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function 
  6. * @since 1.0.0 
  7. * @access public 
  8. * @return void 
  9. */ 
  10. function __construct( $field = array(), $value = '', $parent ) { 
  11. $this->parent = $parent; 
  12. $this->field = $field; 
  13. $this->value = $value; 
  14.  
  15. /** 
  16. * Field Render Function. 
  17. * Takes the vars and outputs the HTML for the field in the settingss 
  18. * @since 1.0.0 
  19. * @access public 
  20. * @return void 
  21. */ 
  22. public function render() { 
  23. if (empty($this->field['palettes'])) { 
  24. echo 'No palettes have been set.'; 
  25. return; 
  26.  
  27. echo '<div id="' . $this->field['id'] . '" class="buttonset">'; 
  28.  
  29. foreach ( $this->field['palettes'] as $value => $colorSet ) { 
  30. $checked = checked( $this->value , $value, false ); 
  31. echo '<input type="radio" value="' . $value . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" class="redux-palette-set ' . $this->field['class'] . '" id="' . $this->field['id'] . '-' . $value . '"' . $checked . '>'; 
  32. echo '<label for="' . $this->field['id'] . '-' . $value . '">'; 
  33.  
  34. foreach ( $colorSet as $color ) { 
  35. printf( "<span style='background: {$color}'>{$color}</span>" ); 
  36. }  
  37.  
  38. echo '</label>'; 
  39. echo '</input>'; 
  40.  
  41. echo '</div>'; 
  42.  
  43. /** 
  44. * Enqueue Function. 
  45. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  46. * @since 1.0.0 
  47. * @access public 
  48. * @return void 
  49. */ 
  50. public function enqueue() { 
  51. $min = Redux_Functions::isMin(); 
  52.  
  53. wp_enqueue_script( 
  54. 'redux-field-palette-js',  
  55. ReduxFramework::$_url . 'inc/fields/palette/field_palette' . $min . '.js',  
  56. array( 'jquery', 'redux-js', 'jquery-ui-button', 'jquery-ui-core' ),  
  57. time(),  
  58. true 
  59. );  
  60.  
  61. if ($this->parent->args['dev_mode']) { 
  62. wp_enqueue_style( 
  63. 'redux-field-palette-css',  
  64. ReduxFramework::$_url . 'inc/fields/palette/field_palette.css',  
  65. array(),  
  66. time(),  
  67. 'all' 
  68. ); 
  69. }  
  70. }  
  71.  
  72.  
  73. public function output() { 
  74.