| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Redux Framework is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* any later version. |
| 8 |
* Redux Framework is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* You should have received a copy of the GNU General Public License |
| 13 |
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>. |
| 14 |
* |
| 15 |
* @package ReduxFramework |
| 16 |
* @subpackage Field_Palette |
| 17 |
* @author Kevin Provance (kprovance) |
| 18 |
* @version 3.5.4 |
| 19 |
*/ |
| 20 |
|
| 21 |
// Exit if accessed directly |
| 22 |
if ( ! defined( 'ABSPATH' ) ) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
if ( ! class_exists( 'ReduxFramework_palette' ) ) { |
| 27 |
class ReduxFramework_palette { |
| 28 |
|
| 29 |
/** |
| 30 |
* Field Constructor. |
| 31 |
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function |
| 32 |
* |
| 33 |
* @since 1.0.0 |
| 34 |
* @access public |
| 35 |
* @return void |
| 36 |
*/ |
| 37 |
function __construct( $field = array(), $value = '', $parent ) { |
| 38 |
$this->parent = $parent; |
| 39 |
$this->field = $field; |
| 40 |
$this->value = $value; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Field Render Function. |
| 45 |
* Takes the vars and outputs the HTML for the field in the settingss |
| 46 |
* |
| 47 |
* @since 1.0.0 |
| 48 |
* @access public |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public function render() { |
| 52 |
if (empty($this->field['palettes'])) { |
| 53 |
echo 'No palettes have been set.'; |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
echo '<div id="' . $this->field['id'] . '" class="buttonset">'; |
| 58 |
|
| 59 |
foreach ( $this->field['palettes'] as $value => $colorSet ) { |
| 60 |
$checked = checked( $this->value , $value, false ); |
| 61 |
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 . '>'; |
| 62 |
echo '<label for="' . $this->field['id'] . '-' . $value . '">'; |
| 63 |
|
| 64 |
foreach ( $colorSet as $color ) { |
| 65 |
printf( "<span style='background: {$color}'>{$color}</span>" ); |
| 66 |
} |
| 67 |
|
| 68 |
echo '</label>'; |
| 69 |
echo '</input>'; |
| 70 |
} |
| 71 |
|
| 72 |
echo '</div>'; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Enqueue Function. |
| 77 |
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
| 78 |
* |
| 79 |
* @since 1.0.0 |
| 80 |
* @access public |
| 81 |
* @return void |
| 82 |
*/ |
| 83 |
public function enqueue() { |
| 84 |
$min = Redux_Functions::isMin(); |
| 85 |
|
| 86 |
wp_enqueue_script( |
| 87 |
'redux-field-palette-js', |
| 88 |
ReduxFramework::$_url . 'inc/fields/palette/field_palette' . $min . '.js', |
| 89 |
array( 'jquery', 'redux-js', 'jquery-ui-button', 'jquery-ui-core' ), |
| 90 |
time(), |
| 91 |
true |
| 92 |
); |
| 93 |
|
| 94 |
if ($this->parent->args['dev_mode']) { |
| 95 |
wp_enqueue_style( |
| 96 |
'redux-field-palette-css', |
| 97 |
ReduxFramework::$_url . 'inc/fields/palette/field_palette.css', |
| 98 |
array(), |
| 99 |
time(), |
| 100 |
'all' |
| 101 |
); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
public function output() { |
| 107 |
|
| 108 |
} |
| 109 |
} |
| 110 |
} |