PluginProbe
QuadMenu – Mega Menu / 1.8.9
QuadMenu – Mega Menu v1.8.9
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / redux / animation / field_animation.php

field_animation.php in QuadMenu – Mega Menu 1.8.9, at lib/redux/animation/field_animation.php

191 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 if (!class_exists('ReduxFramework_animation')) {
8
9 class ReduxFramework_animation {
10
11 public $_extension_url;
12 public $_extension_dir;
13
14 function __construct($field = array(), $value = '', $parent) {
15 $this->parent = $parent;
16 $this->field = $field;
17 $this->value = $value;
18
19 if (empty(self::$_extension_dir)) {
20 $this->_extension_dir = trailingslashit(str_replace('\\', '/', dirname(__FILE__)));
21 $this->_extension_url = site_url(str_replace(trailingslashit(str_replace('\\', '/', ABSPATH)), '', $this->_extension_dir));
22 }
23
24 // No errors please
25 $defaults = array(
26 'speed' => false,
27 'action' => false,
28 'options' => '',
29 'mode' => array(
30 'speed' => false,
31 'action' => false,
32 ),
33 );
34
35 $this->field = wp_parse_args($this->field, $defaults);
36
37 $defaults = array(
38 'speed' => '',
39 'action' => '',
40 'options' => ''
41 );
42
43 $this->value = wp_parse_args($this->value, $defaults);
44 }
45
46 function render() {
47
48 echo '<fieldset id="' . $this->field['id'] . '" class="redux-animation-container" data-id="' . $this->field['id'] . '">';
49
50 if (isset($this->field['select2'])) {
51
52 $select2_params = json_encode($this->field['select2']);
53
54 $select2_params = htmlspecialchars($select2_params, ENT_QUOTES);
55
56 echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">';
57 }
58
59 //echo '<input id="' . $this->field['id'] . '" name="' . $this->field['name'] . '" type="text" value="' . $this->value . '">';
60
61 if (isset($this->field['options']) && is_array($this->field['options'])) {
62
63 echo '<input name="' . $this->field['name'] . '[options]' . '" type="hidden" class="field-options" value="' . $this->value['options'] . '">';
64
65 echo '<div class="select_wrapper animation-options" original-title="' . __('options', 'quadmenu') . '">';
66
67 echo '<select data-key="' . $this->field['name'] . '" data-id="' . $this->field['id'] . '" data-placeholder="' . __('options', 'quadmenu') . '" class="redux-animation redux-animation-options select ' . $this->field['class'] . '" original-title="' . __('options', 'quadmenu') . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[options]' . '">';
68
69 if (isset($this->field['options']) && is_array($this->field['options'])) {
70
71 foreach ($this->field['options'] as $animation => $name) {
72 echo '<option value="' . $animation . '" ' . selected($this->value['options'], $animation, false) . '>' . $name . '</option>';
73 }
74 }
75
76 echo '</select>';
77 echo '</div>';
78 };
79
80 if (isset($this->field['action']) && is_array($this->field['action'])) {
81
82 echo '<input name="' . $this->field['name'] . '[action]' . '" type="hidden" class="field-action" value="' . $this->value['action'] . '">';
83
84 echo '<div class="select_wrapper animation-action" original-title="' . __('action', 'quadmenu') . '">';
85
86 echo '<select data-key="' . $this->field['name'] . '" data-id="' . $this->field['id'] . '" data-placeholder="' . __('action', 'quadmenu') . '" class="redux-animation redux-animation-action select ' . $this->field['class'] . '" original-title="' . __('action', 'quadmenu') . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[action]' . '">';
87
88 if (isset($this->field['action']) && is_array($this->field['action'])) {
89
90 foreach ($this->field['action'] as $action => $name) {
91 echo '<option value="' . $action . '" ' . selected($this->value['action'], $action, false) . '>' . $name . '</option>';
92 }
93 }
94
95 echo '</select>';
96 echo '</div>';
97 };
98
99 if (isset($this->field['speed']) && is_array($this->field['speed'])) {
100
101 echo '<input name="' . $this->field['name'] . '[speed]' . '" type="hidden" class="field-speed" value="' . $this->value['speed'] . '">';
102
103 echo '<div class="select_wrapper animation-speed" original-title="' . __('speed', 'quadmenu') . '">';
104
105 echo '<select data-key="' . $this->field['name'] . '" data-id="' . $this->field['id'] . '" data-placeholder="' . __('speed', 'quadmenu') . '" class="redux-animation redux-animation-speed select ' . $this->field['class'] . '" original-title="' . __('speed', 'quadmenu') . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[speed]' . '">';
106
107 if (isset($this->field['speed']) && is_array($this->field['speed'])) {
108
109 foreach ($this->field['speed'] as $speed => $name) {
110 echo '<option value="' . $speed . '" ' . selected($this->value['speed'], $speed, false) . '>' . $name . '</option>';
111 }
112 }
113
114 echo '</select>';
115 echo '</div>';
116 };
117
118 echo "</fieldset>";
119 }
120
121 function enqueue() {
122 wp_enqueue_style('select2-css');
123
124 wp_enqueue_style(
125 'redux-field-animation-css', $this->_extension_url . 'field_animation' . Redux_Functions::isMin() . '.css', array(), time(), 'all'
126 );
127
128 wp_enqueue_script(
129 'redux-field-animation-js', $this->_extension_url . 'field_animation' . Redux_Functions::isMin() . '.js', array('jquery', 'select2-js', 'redux-js'), time(), true
130 );
131 }
132
133 public function output() {
134
135 // if field options has a value and IS an array, then evaluate as needed.
136 if (isset($this->field['options']) && !is_array($this->field['options'])) {
137
138 //if options fields has a value but options value does not then make options value the field value
139 if (isset($this->field['options']) && !isset($this->value['options']) || $this->field['options'] == false) {
140 $this->value['options'] = $this->field['options'];
141
142 // If options field does NOT have a value and options value does NOT have a value, set both to blank (default?)
143 } else if (!isset($this->field['options']) && !isset($this->value['options'])) {
144 $this->field['options'] = 'px';
145 $this->value['options'] = 'px';
146
147 // If options field has NO value but options value does, then set unit field to value field
148 } else if (!isset($this->field['options']) && isset($this->value['options'])) {
149 $this->field['options'] = $this->value['options'];
150
151 // if unit value is set and unit value doesn't equal unit field (coz who knows why)
152 // then set unit value to unit field
153 } elseif (isset($this->value['options']) && $this->value['options'] !== $this->field['options']) {
154 $this->value['options'] = $this->field['options'];
155 }
156
157 // do stuff based on unit field NOT set as an array
158 } elseif (isset($this->field['options']) && is_array($this->field['options'])) {
159 // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
160 }
161
162 $options = isset($this->value['options']) ? $this->value['options'] : "";
163 $action = isset($this->value['action']) ? $this->value['action'] : "";
164 $speed = isset($this->value['speed']) ? $this->value['speed'] : "";
165
166
167 $style = "";
168
169 foreach ($cleanValue as $key => $value) {
170 // Output if it's a numeric entry
171 if (isset($value) && is_numeric($value)) {
172 $style .= $key . ':' . $value . $options . ';';
173 }
174 }
175
176 if (!empty($style)) {
177 if (!empty($this->field['output']) && is_array($this->field['output'])) {
178 $keys = implode(",", $this->field['output']);
179 $this->parent->outputCSS .= $keys . "{" . $style . '}';
180 }
181
182 if (!empty($this->field['compiler']) && is_array($this->field['compiler'])) {
183 $keys = implode(",", $this->field['compiler']);
184 $this->parent->compilerCSS .= $keys . "{" . $style . '}';
185 }
186 }
187 }
188
189 }
190
191 }