ReduxFramework_color

Main ReduxFramework_color class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/color/field_color.php  
  1. class ReduxFramework_color { 
  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.  
  12. $this->parent = $parent; 
  13. $this->field = $field; 
  14. $this->value = $value; 
  15.  
  16. /** 
  17. * Field Render Function. 
  18. * Takes the vars and outputs the HTML for the field in the settings 
  19. * @since 1.0.0 
  20. * @access public 
  21. * @return void 
  22. */ 
  23. public function render() { 
  24.  
  25. echo '<input data-id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-color" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" value="' . $this->value . '" data-oldcolor="" data-default-color="' . ( isset( $this->field['default'] ) ? $this->field['default'] : "" ) . '" />'; 
  26. echo '<input type="hidden" class="redux-saved-color" id="' . $this->field['id'] . '-saved-color' . '" value="">'; 
  27.  
  28. if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) { 
  29.  
  30. $tChecked = ""; 
  31.  
  32. if ( $this->value == "transparent" ) { 
  33. $tChecked = ' checked="checked"'; 
  34.  
  35. echo '<label for="' . $this->field['id'] . '-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency ' . $this->field['class'] . '" id="' . $this->field['id'] . '-transparency" data-id="' . $this->field['id'] . '-color" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>'; 
  36.  
  37. /** 
  38. * Enqueue Function. 
  39. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  40. * @since 1.0.0 
  41. * @access public 
  42. * @return void 
  43. */ 
  44. public function enqueue() { 
  45. wp_enqueue_script( 
  46. 'redux-field-color-js',  
  47. ReduxFramework::$_url . 'inc/fields/color/field_color' . Redux_Functions::isMin() . '.js',  
  48. array( 'jquery', 'wp-color-picker', 'redux-js' ),  
  49. time(),  
  50. true 
  51. ); 
  52.  
  53. public function output() { 
  54. $style = ''; 
  55.  
  56. if ( ! empty( $this->value ) ) { 
  57. $mode = ( isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'color' ); 
  58.  
  59. $style .= $mode . ':' . $this->value . ';'; 
  60.  
  61. if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) { 
  62. $css = Redux_Functions::parseCSS( $this->field['output'], $style, $this->value ); 
  63. $this->parent->outputCSS .= $css; 
  64.  
  65. if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) { 
  66. $css = Redux_Functions::parseCSS( $this->field['compiler'], $style, $this->value ); 
  67. $this->parent->compilerCSS .= $css; 
  68.