PageRenderTime 58ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/oldpaper/framework/redux-framework-master/ReduxCore/inc/fields/link_color/field_link_color.php

https://gitlab.com/eita/agencia-consumo-responsavel
PHP | 207 lines | 123 code | 33 blank | 51 comment | 40 complexity | c14c228474e674f00594a91e024c96a9 MD5 | raw file
  1. <?php
  2. /**
  3. * Redux Framework is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * any later version.
  7. * Redux Framework is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. * You should have received a copy of the GNU General Public License
  12. * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
  13. *
  14. * @package ReduxFramework
  15. * @subpackage Field_Color_Gradient
  16. * @author Luciano "WebCaos" Ubertini
  17. * @author Daniel J Griffiths (Ghost1227)
  18. * @author Dovy Paukstys
  19. * @version 3.0.0
  20. */
  21. // Exit if accessed directly
  22. if ( ! defined( 'ABSPATH' ) ) {
  23. exit;
  24. }
  25. // Don't duplicate me!
  26. if ( ! class_exists( 'ReduxFramework_link_color' ) ) {
  27. /**
  28. * Main ReduxFramework_link_color class
  29. *
  30. * @since 1.0.0
  31. */
  32. class ReduxFramework_link_color {
  33. /**
  34. * Field Constructor.
  35. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
  36. *
  37. * @since 1.0.0
  38. * @access public
  39. * @return void
  40. */
  41. function __construct( $field = array(), $value = '', $parent ) {
  42. $this->parent = $parent;
  43. $this->field = $field;
  44. $this->value = $value;
  45. $defaults = array(
  46. 'regular' => true,
  47. 'hover' => true,
  48. 'visited' => false,
  49. 'active' => true
  50. );
  51. $this->field = wp_parse_args( $this->field, $defaults );
  52. $defaults = array(
  53. 'regular' => '',
  54. 'hover' => '',
  55. 'visited' => '',
  56. 'active' => ''
  57. );
  58. $this->value = wp_parse_args( $this->value, $defaults );
  59. // In case user passes no default values.
  60. if ( isset( $this->field['default'] ) ) {
  61. $this->field['default'] = wp_parse_args( $this->field['default'], $defaults );
  62. } else {
  63. $this->field['default'] = $defaults;
  64. }
  65. }
  66. /**
  67. * Field Render Function.
  68. * Takes the vars and outputs the HTML for the field in the settings
  69. *
  70. * @since 1.0.0
  71. * @access public
  72. * @return void
  73. */
  74. public function render() {
  75. if ( $this->field['regular'] === true && $this->field['default']['regular'] !== false ) {
  76. echo '<span class="linkColor"><strong>' . __( 'Regular', 'redux-framework' ) . '</strong>&nbsp;<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>';
  77. }
  78. if ( $this->field['hover'] === true && $this->field['default']['hover'] !== false ) {
  79. echo '<span class="linkColor"><strong>' . __( 'Hover', 'redux-framework' ) . '</strong>&nbsp;<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>';
  80. }
  81. if ( $this->field['visited'] === true && $this->field['default']['visited'] !== false ) {
  82. echo '<span class="linkColor"><strong>' . __( 'Visited', 'redux-framework' ) . '</strong>&nbsp;<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>';
  83. }
  84. if ( $this->field['active'] === true && $this->field['default']['active'] !== false ) {
  85. echo '<span class="linkColor"><strong>' . __( 'Active', 'redux-framework' ) . '</strong>&nbsp;<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>';
  86. }
  87. }
  88. /**
  89. * Enqueue Function.
  90. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  91. *
  92. * @since 1.0.0
  93. * @access public
  94. * @return void
  95. */
  96. public function enqueue() {
  97. wp_enqueue_style( 'wp-color-picker' );
  98. wp_enqueue_script(
  99. 'redux-field-link-color-js',
  100. ReduxFramework::$_url . 'inc/fields/link_color/field_link_color' . Redux_Functions::isMin() . '.js',
  101. array( 'jquery', 'wp-color-picker', 'redux-js' ),
  102. time(),
  103. true
  104. );
  105. if ($this->parent->args['dev_mode']) {
  106. wp_enqueue_style( 'redux-color-picker-css' );
  107. wp_enqueue_style(
  108. 'redux-field-link_color-js',
  109. ReduxFramework::$_url . 'inc/fields/link_color/field_link_color.css',
  110. array(),
  111. time(),
  112. 'all'
  113. );
  114. }
  115. }
  116. public function output() {
  117. $style = array();
  118. if ( ! empty( $this->value['regular'] ) && $this->field['regular'] === true && $this->field['default']['regular'] !== false ) {
  119. $style[] = 'color:' . $this->value['regular'] . ';';
  120. }
  121. if ( ! empty( $this->value['visited'] ) && $this->field['visited'] === true && $this->field['default']['visited'] !== false ) {
  122. $style['visited'] = 'color:' . $this->value['visited'] . ';';
  123. }
  124. if ( ! empty( $this->value['hover'] ) && $this->field['hover'] === true && $this->field['default']['hover'] !== false ) {
  125. $style['hover'] = 'color:' . $this->value['hover'] . ';';
  126. }
  127. if ( ! empty( $this->value['active'] ) && $this->field['active'] === true && $this->field['default']['active'] !== false ) {
  128. $style['active'] = 'color:' . $this->value['active'] . ';';
  129. }
  130. if ( ! empty( $style ) ) {
  131. if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
  132. $styleString = "";
  133. foreach ( $style as $key => $value ) {
  134. if ( is_numeric( $key ) ) {
  135. $styleString .= implode( ",", $this->field['output'] ) . "{" . $value . '}';
  136. } else {
  137. if ( count( $this->field['output'] ) == 1 ) {
  138. $styleString .= $this->field['output'][0] . ":" . $key . "{" . $value . '}';
  139. } else {
  140. $blah = '';
  141. foreach($this->field['output'] as $k => $sel) {
  142. $blah .= $sel . ':' . $key . ',';
  143. }
  144. $blah = substr($blah, 0, strlen($blah) - 1);
  145. $styleString .= $blah . '{' . $value . '}';
  146. }
  147. }
  148. }
  149. $this->parent->outputCSS .= $styleString;
  150. }
  151. if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
  152. $styleString = "";
  153. foreach ( $style as $key => $value ) {
  154. if ( is_numeric( $key ) ) {
  155. $styleString .= implode( ",", $this->field['compiler'] ) . "{" . $value . '}';
  156. } else {
  157. if ( count( $this->field['compiler'] ) == 1 ) {
  158. $styleString .= $this->field['compiler'][0] . ":" . $key . "{" . $value . '}';
  159. } else {
  160. $blah = '';
  161. foreach($this->field['compiler'] as $k => $sel) {
  162. $blah .= $sel . ':' . $key . ',';
  163. }
  164. $blah = substr($blah, 0, strlen($blah) - 1);
  165. $styleString .= $blah . '{' . $value . '}';
  166. }
  167. }
  168. }
  169. $this->parent->compilerCSS .= $styleString;
  170. }
  171. }
  172. }
  173. }
  174. }