ReduxFramework_link_color

Main ReduxFramework_link_color class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/link_color/field_link_color.php  
  1. class ReduxFramework_link_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. $this->parent = $parent; 
  12. $this->field = $field; 
  13. $this->value = $value; 
  14.  
  15. $defaults = array( 
  16. 'regular' => true,  
  17. 'hover' => true,  
  18. 'visited' => false,  
  19. 'active' => true 
  20. ); 
  21. $this->field = wp_parse_args( $this->field, $defaults ); 
  22.  
  23. $defaults = array( 
  24. 'regular' => '',  
  25. 'hover' => '',  
  26. 'visited' => '',  
  27. 'active' => '' 
  28. ); 
  29.  
  30. $this->value = wp_parse_args( $this->value, $defaults ); 
  31.  
  32. // In case user passes no default values. 
  33. if ( isset( $this->field['default'] ) ) { 
  34. $this->field['default'] = wp_parse_args( $this->field['default'], $defaults ); 
  35. } else { 
  36. $this->field['default'] = $defaults; 
  37.  
  38. /** 
  39. * Field Render Function. 
  40. * Takes the vars and outputs the HTML for the field in the settings 
  41. * @since 1.0.0 
  42. * @access public 
  43. * @return void 
  44. */ 
  45. public function render() { 
  46.  
  47. if ( $this->field['regular'] === true && $this->field['default']['regular'] !== false ) { 
  48. echo '<span class="linkColor"><strong>' . __( 'Regular', 'redux-framework' ) . '</strong> <input id="' . $this->field['id'] . '-regular" name="' . $this->field['name'] . $this->field['name_suffix'] . '[regular]' . '" value="' . $this->value['regular'] . '" class="redux-color redux-color-regular redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['regular'] . '" /></span>'; 
  49.  
  50. if ( $this->field['hover'] === true && $this->field['default']['hover'] !== false ) { 
  51. echo '<span class="linkColor"><strong>' . __( 'Hover', 'redux-framework' ) . '</strong> <input id="' . $this->field['id'] . '-hover" name="' . $this->field['name'] . $this->field['name_suffix'] . '[hover]' . '" value="' . $this->value['hover'] . '" class="redux-color redux-color-hover redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['hover'] . '" /></span>'; 
  52.  
  53. if ( $this->field['visited'] === true && $this->field['default']['visited'] !== false ) { 
  54. echo '<span class="linkColor"><strong>' . __( 'Visited', 'redux-framework' ) . '</strong> <input id="' . $this->field['id'] . '-hover" name="' . $this->field['name'] . $this->field['name_suffix'] . '[visited]' . '" value="' . $this->value['visited'] . '" class="redux-color redux-color-visited redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['visited'] . '" /></span>'; 
  55.  
  56. if ( $this->field['active'] === true && $this->field['default']['active'] !== false ) { 
  57. echo '<span class="linkColor"><strong>' . __( 'Active', 'redux-framework' ) . '</strong> <input id="' . $this->field['id'] . '-active" name="' . $this->field['name'] . $this->field['name_suffix'] . '[active]' . '" value="' . $this->value['active'] . '" class="redux-color redux-color-active redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['active'] . '" /></span>'; 
  58.  
  59. /** 
  60. * Enqueue Function. 
  61. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  62. * @since 1.0.0 
  63. * @access public 
  64. * @return void 
  65. */ 
  66. public function enqueue() { 
  67.  
  68. wp_enqueue_script( 
  69. 'redux-field-link-color-js',  
  70. ReduxFramework::$_url . 'inc/fields/link_color/field_link_color' . Redux_Functions::isMin() . '.js',  
  71. array( 'jquery', 'wp-color-picker', 'redux-js' ),  
  72. time(),  
  73. true 
  74. ); 
  75.  
  76. redux_enqueue_style( 
  77. $this->parent,  
  78. 'redux-field-link_color-css',  
  79. ReduxFramework::$_url . 'inc/fields/link_color/field_link_color.css',  
  80. ReduxFramework::$_dir . 'inc/fields/link_color',  
  81. array(),  
  82. time(),  
  83. false 
  84. );  
  85.  
  86. // wp_enqueue_style( 
  87. // 'redux-field-link_color-js',  
  88. // ReduxFramework::$_url . 'inc/fields/link_color/field_link_color.css',  
  89. // time(),  
  90. // true 
  91. // ); 
  92.  
  93. public function output() { 
  94.  
  95. $style = array(); 
  96.  
  97. if ( ! empty( $this->value['regular'] ) && $this->field['regular'] === true && $this->field['default']['regular'] !== false ) { 
  98. $style[] = 'color:' . $this->value['regular'] . ';'; 
  99.  
  100. if ( ! empty( $this->value['visited'] ) && $this->field['visited'] === true && $this->field['default']['visited'] !== false ) { 
  101. $style['visited'] = 'color:' . $this->value['visited'] . ';'; 
  102.  
  103. if ( ! empty( $this->value['hover'] ) && $this->field['hover'] === true && $this->field['default']['hover'] !== false ) { 
  104. $style['hover'] = 'color:' . $this->value['hover'] . ';'; 
  105.  
  106. if ( ! empty( $this->value['active'] ) && $this->field['active'] === true && $this->field['default']['active'] !== false ) { 
  107. $style['active'] = 'color:' . $this->value['active'] . ';'; 
  108.  
  109. if ( ! empty( $style ) ) { 
  110. if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) { 
  111. $styleString = ""; 
  112.  
  113. foreach ( $style as $key => $value ) { 
  114. if ( is_numeric( $key ) ) { 
  115. $styleString .= implode( ", ", $this->field['output'] ) . "{" . $value . '}'; 
  116. } else { 
  117. if ( count( $this->field['output'] ) == 1 ) { 
  118. $styleString .= $this->field['output'][0] . ":" . $key . "{" . $value . '}'; 
  119. } else { 
  120. $blah = ''; 
  121. foreach($this->field['output'] as $k => $sel) { 
  122. $blah .= $sel . ':' . $key . ', '; 
  123.  
  124. $blah = substr($blah, 0, strlen($blah) - 1); 
  125. $styleString .= $blah . '{' . $value . '}'; 
  126.  
  127.  
  128. $this->parent->outputCSS .= $styleString; 
  129.  
  130. if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) { 
  131. $styleString = ""; 
  132.  
  133. foreach ( $style as $key => $value ) { 
  134. if ( is_numeric( $key ) ) { 
  135. $styleString .= implode( ", ", $this->field['compiler'] ) . "{" . $value . '}'; 
  136.  
  137. } else { 
  138. if ( count( $this->field['compiler'] ) == 1 ) { 
  139. $styleString .= $this->field['compiler'][0] . ":" . $key . "{" . $value . '}'; 
  140. } else { 
  141. $blah = ''; 
  142. foreach($this->field['compiler'] as $k => $sel) { 
  143. $blah .= $sel . ':' . $key . ', '; 
  144.  
  145. $blah = substr($blah, 0, strlen($blah) - 1); 
  146. $styleString .= $blah . '{' . $value . '}'; 
  147. $this->parent->compilerCSS .= $styleString;