/wp-content/themes/osmosis/includes/framework/inc/fields/color_gradient/field_color_gradient.php

https://github.com/Canuckaholic/Pop-Digital · PHP · 121 lines · 55 code · 16 blank · 50 comment · 10 complexity · 7dccdd917e6f288ed8a99a3be945b1bc 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 Daniel J Griffiths (Ghost1227)
  17. * @author Dovy Paukstys
  18. * @version 3.0.0
  19. */
  20. // Exit if accessed directly
  21. if ( ! defined( 'ABSPATH' ) ) {
  22. exit;
  23. }
  24. // Don't duplicate me!
  25. if ( ! class_exists( 'ReduxFramework_color_gradient' ) ) {
  26. /**
  27. * Main ReduxFramework_color_gradient class
  28. *
  29. * @since 1.0.0
  30. */
  31. class ReduxFramework_color_gradient {
  32. /**
  33. * Field Constructor.
  34. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
  35. *
  36. * @since 1.0.0
  37. * @access public
  38. * @return void
  39. */
  40. function __construct( $field = array(), $value = '', $parent ) {
  41. $this->parent = $parent;
  42. $this->field = $field;
  43. $this->value = $value;
  44. }
  45. /**
  46. * Field Render Function.
  47. * Takes the vars and outputs the HTML for the field in the settings
  48. *
  49. * @since 1.0.0
  50. * @access public
  51. * @return void
  52. */
  53. public function render() {
  54. // No errors please
  55. $defaults = array(
  56. 'from' => '',
  57. 'to' => ''
  58. );
  59. $this->value = wp_parse_args( $this->value, $defaults );
  60. echo '<div class="colorGradient"><strong>' . __( 'From ', 'redux-framework' ) . '</strong>&nbsp;';
  61. echo '<input data-id="' . $this->field['id'] . '" id="' . $this->field['id'] . '-from" name="' . $this->field['name'] . $this->field['name_suffix'] . '[from]' . '" value="' . $this->value['from'] . '" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['from'] . '" />';
  62. echo '<input type="hidden" class="redux-saved-color" id="' . $this->field['id'] . '-saved-color' . '" value="">';
  63. if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
  64. $tChecked = "";
  65. if ( $this->value['from'] == "transparent" ) {
  66. $tChecked = ' checked="checked"';
  67. }
  68. echo '<label for="' . $this->field['id'] . '-from-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency ' . $this->field['class'] . '" id="' . $this->field['id'] . '-from-transparency" data-id="' . $this->field['id'] . '-from" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
  69. }
  70. echo "</div>";
  71. echo '<div class="colorGradient toLabel"><strong>' . __( 'To ', 'redux-framework' ) . '</strong>&nbsp;<input data-id="' . $this->field['id'] . '" id="' . $this->field['id'] . '-to" name="' . $this->field['name'] . $this->field['name_suffix'] . '[to]' . '" value="' . $this->value['to'] . '" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['to'] . '" />';
  72. if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
  73. $tChecked = "";
  74. if ( $this->value['to'] == "transparent" ) {
  75. $tChecked = ' checked="checked"';
  76. }
  77. echo '<label for="' . $this->field['id'] . '-to-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency" id="' . $this->field['id'] . '-to-transparency" data-id="' . $this->field['id'] . '-to" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
  78. }
  79. echo "</div>";
  80. }
  81. /**
  82. * Enqueue Function.
  83. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  84. *
  85. * @since 1.0.0
  86. * @access public
  87. * @return void
  88. */
  89. public function enqueue() {
  90. wp_enqueue_script(
  91. 'redux-field-color-gradient-js',
  92. ReduxFramework::$_url . 'inc/fields/color_gradient/field_color_gradient' . Redux_Functions::isMin() . '.js',
  93. array( 'jquery', 'wp-color-picker', 'redux-js' ),
  94. time(),
  95. true
  96. );
  97. wp_enqueue_style(
  98. 'redux-field-color_gradient-css',
  99. ReduxFramework::$_url . 'inc/fields/color_gradient/field_color_gradient.css',
  100. time(),
  101. true
  102. );
  103. }
  104. }
  105. }