PluginProbe
MaxButtons – Create buttons / 6.28
MaxButtons – Create buttons v6.28
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
← All changes | blocks/gradient.php +172 -116 6.36.28 View file →
@@ -1,188 +1,244 @@
1 1 <?php
2 +namespace MaxButtons;
2 3 defined('ABSPATH') or die('No direct access permitted');
3 -$blockClass["gradient"] = "gradientBlock";
4 +$blockClass["gradient"] = "gradientBlock";
4 5 $blockOrder[40][] = "gradient";
5 -
6 -use MaxButtons\maxBlocks as maxBlocks;
7 -use MaxButtons\maxField as maxField;
8 6
9 -class gradientBlock extends maxBlock
7 +class gradientBlock extends maxBlock
10 8 {
11 - protected $blockname = "gradient";
9 + protected $blockname = "gradient";
12 10 protected $fields = array("gradient_stop" => array("default" => "45",
13 11 "css" => "gradient-stop",
14 - "csspseudo" => "normal,hover",
12 + "csspseudo" => "normal,hover",
15 13 ),
16 14
17 - "gradient_start_opacity" => array("default" => "100",
15 + "gradient_start_opacity" => array("default" => "100",
18 16 "css" => "gradient-start-opacity"),
19 - "gradient_end_opacity" => array("default" => "100",
17 + "gradient_end_opacity" => array("default" => "100",
20 18 "css" => "gradient-end-opacity"),
21 - "gradient_start_opacity_hover" => array("default" => "100",
19 + "gradient_start_opacity_hover" => array("default" => "100",
22 20 "css" => "gradient-start-opacity",
23 - "csspseudo" => "hover"),
21 + "csspseudo" => "hover"),
24 22 "gradient_end_opacity_hover" => array("default" => "100",
25 - "css" => "gradient-end-opacity",
23 + "css" => "gradient-end-opacity",
26 24 "csspseudo" => "hover"),
27 -
28 - );
29 -
25 + 'use_gradient' => array('default' => '0',
26 + 'css' => 'gradient-use-gradient',
27 + 'csspseudo' => 'normal,hover',
28 + ),
30 29
30 + );
31 +
32 +
31 33 public function map_fields($map)
32 34 {
33 -
34 - $map["gradient_stop"]["func"] = "updateGradientOpacity";
35 - $map["gradient_start_opacity"]["func"] = "updateGradientOpacity";
36 - $map["gradient_end_opacity"]["func"] = "updateGradientOpacity";
37 - $map["gradient_start_opacity_hover"]["func"] = "updateGradientOpacity";
38 - $map["gradient_end_opacity_hover"]["func"] = "updateGradientOpacity";
39 -
40 - return $map;
35 +
36 + $map["gradient_stop"]["func"] = "updateGradientOpacity";
37 + $map["gradient_start_opacity"]["func"] = "updateGradientOpacity";
38 + $map["gradient_end_opacity"]["func"] = "updateGradientOpacity";
39 + $map["gradient_start_opacity_hover"]["func"] = "updateGradientOpacity";
40 + $map["gradient_end_opacity_hover"]["func"] = "updateGradientOpacity";
41 +
42 + return $map;
41 43 }
42 44
43 45
44 - public function admin_fields()
46 + public function admin_fields()
45 47 {
46 - $data = $this->data[$this->blockname];
47 - foreach($this->fields as $field => $options)
48 - {
49 - $default = (isset($options["default"])) ? $options["default"] : '';
50 - $$field = (isset($data[$field])) ? $data[$field] : $default;
51 - ${$field . "_default"} = $default;
52 - }
53 -?>
48 + $data = $this->data[$this->blockname];
49 +
50 +?>
54 51 <div class="mb_tab option-container gradient-options">
55 52 <div class="title"><?php _e('Background', 'maxbuttons') ?></div>
56 53 <div class="inside">
57 54 <?php
58 55
56 + $g_start = maxBlocks::getColorValue('gradient_start_color');
57 + $g_end = maxBlocks::getColorValue('gradient_end_color');
58 + $gh_start = maxBlocks::getColorValue('gradient_start_color_hover');
59 + $gh_end = maxBlocks::getColorValue('gradient_end_color_hover');
60 +
61 + $use_gradient = maxBlocks::getValue('use_gradient');
62 +
63 + if (! isset($data['use_gradient'] ))
64 + {
65 + if ($g_start != $g_end || $gh_start != $gh_end)
66 + $use_gradient = true;
67 + else
68 + $use_gradient = false;
69 +
70 + }
71 +
72 + $condition = array('target' => 'use_gradient', 'values' => 'checked');
73 + $gradient_conditional = htmlentities(json_encode($condition));
74 +
75 + $color_copy_self = __("Replace color from other field", "maxbuttons");
76 + $color_copy_move = __("Copy Color to other field", "maxbuttons");
77 + // $fspacer->output('start');
78 +
79 + $useg = new maxField('switch');
80 + $useg->label = __('Use Gradients', 'maxbuttons');
81 + $useg->name = 'use_gradient';
82 + $useg->id = $useg->name;
83 + $useg->value = '1';
84 + $useg->checked = checked($use_gradient, 1, false);
85 + $useg->output ('start','end');
86 +
59 87 // Spacer
60 - $fspacer = new maxField('spacer');
88 + $fspacer = new maxField('spacer');
61 89 $fspacer->label = '&nbsp;';
62 - $fspacer->name = 'gradient_head';
63 - $fspacer->output('start');
90 + $fspacer->name = 'gradient_head';
91 + $fspacer->output('start');
64 92
65 93 // Spacer
66 - $fspacer = new maxField('spacer');
94 + //$fspacer = new maxField('spacer');
67 95 $fspacer->label = __('Start','maxbuttons');
68 - $fspacer->name = 'gradient_start';
96 + $fspacer->name = 'gradient_start';
69 97 $fspacer->output('');
70 -
98 +
71 99 // Spacer
72 - $fspacer = new maxField('spacer');
100 + //$fspacer = new maxField('spacer');
73 101 $fspacer->label = __('End','maxbuttons');
74 - $fspacer->name = 'gradient_end';
75 - $fspacer->output('', 'end');
76 -
102 + $fspacer->name = 'gradient_end';
103 + $fspacer->conditional = $gradient_conditional;
104 + $fspacer->output('', 'end');
105 +
77 106 // Background Color
78 - $color = new maxField('color');
79 - $color->id = 'gradient_start_color';
80 - $color->name = $color->id;
81 - $color->value = maxBlocks::getValue('gradient_start_color');
82 - $color->label = __('Background color','maxbuttons');
83 - $color->inputclass = 'square';
84 - $color->output('start');
85 -
86 - // Background Color
87 - $ecolor = new maxField('color');
88 - $ecolor->id = 'gradient_end_color';
89 - $ecolor->name = $ecolor->id;
90 - $ecolor->value = maxBlocks::getValue('gradient_end_color');
91 - // $ecolor->label = __('Color end','maxbuttons');
92 - $ecolor->inputclass = 'square';
93 - $ecolor->output('', 'end');
94 -
95 -
96 - // Background Color Hover
97 - $color_hover = new maxField('color');
98 - $color_hover->id = 'gradient_start_color_hover';
99 - $color_hover->name = $color_hover->id;
100 - $color_hover->value = maxBlocks::getValue('gradient_start_color_hover');
101 - $color_hover->label = __('Background hover','maxbuttons');
102 - $color_hover->inputclass = 'square';
103 - $color_hover->output('start','');
107 + $color = new maxField('color');
108 + $color->id = 'gradient_start_color';
109 + $color->name = $color->id;
110 + $color->value = $g_start;
111 + $color->label = __('Background color','maxbuttons');
112 + $color->inputclass = 'square';
113 + $color->copycolor = true;
114 + $color->bindto = 'gradient_end_color';
115 + $color->left_title = $color_copy_self;
116 + $color->right_title = $color_copy_move;
117 + $color->copypos = 'right';
104 118
105 - // Background Color Hover
106 - $ecolor_hover = new maxField('color');
107 - $ecolor_hover->id = 'gradient_end_color_hover';
108 - $ecolor_hover->name = $ecolor_hover->id;
109 - $ecolor_hover->value = maxBlocks::getValue('gradient_end_color_hover');
110 - $ecolor_hover->inputclass = 'square';
111 - // $ecolor_hover->label = __('Color Hover End','maxbuttons');
112 - $ecolor_hover->output('','end');
113 -
119 + $color->output('start');
120 +
121 + // Background Color (End Gradient)
122 + $ecolor = new maxField('color');
123 + $ecolor->id = 'gradient_end_color';
124 + $ecolor->name = $ecolor->id;
125 + $ecolor->value = $g_end;
126 + $ecolor->inputclass = 'square';
127 + $ecolor->copycolor = true;
128 + $ecolor->bindto = $color->id;
129 + $ecolor->copypos = 'left';
130 + $ecolor->left_title = $color_copy_move;
131 + $ecolor->right_title = $color_copy_self;
132 + $ecolor->conditional = $gradient_conditional;
133 + $ecolor->output('', 'end');
134 +
135 +
136 + // Background Color Hover
137 + $color_hover = new maxField('color');
138 + $color_hover->id = 'gradient_start_color_hover';
139 + $color_hover->name = $color_hover->id;
140 + $color_hover->value = $gh_start;
141 + $color_hover->label = __('Background hover','maxbuttons');
142 + $color_hover->inputclass = 'square';
143 + $color_hover->copycolor = true;
144 + $color_hover->bindto = 'gradient_end_color_hover';
145 + $color_hover->left_title = $color_copy_self;
146 + $color_hover->right_title = $color_copy_move;
147 + $color_hover->copypos = 'right';
148 +
149 + $color_hover->output('start','');
150 +
151 + // Background Color Hover
152 + $ecolor_hover = new maxField('color');
153 + $ecolor_hover->id = 'gradient_end_color_hover';
154 + $ecolor_hover->name = $ecolor_hover->id;
155 + $ecolor_hover->value = $gh_end;
156 + $ecolor_hover->inputclass = 'square';
157 + // $ecolor_hover->label = __('Color Hover End','maxbuttons');
158 + $ecolor_hover->copycolor = true;
159 + $ecolor_hover->bindto = $color_hover->id;
160 + $ecolor_hover->copypos = 'left';
161 + $ecolor_hover->left_title = $color_copy_move;
162 + $ecolor_hover->right_title = $color_copy_self;
163 + $ecolor_hover->conditional = $gradient_conditional;
164 + $ecolor_hover->output('','end');
165 +
114 166 ?>
115 -
167 +
116 168 <!--
117 169 <p><a href='#'>See more options</a></p>
118 170 -->
119 171 <div id='gradient_fold' class="fold">
120 -
121 - <?php
122 - $startop = new maxField('number');
123 - $startop->label = __('Normal Opacity','maxbuttons');
172 +
173 + <?php
174 + $startop = new maxField('number');
175 + $startop->label = __('Normal Opacity','maxbuttons');
124 176 $startop->name = 'gradient_start_opacity';
125 177 $startop->id = $startop->name;
126 - $startop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_start_opacity') );
178 + $startop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_start_opacity') );
127 179 //$startop->setDefault(maxBlocks::getDefault('gradient_start_opacity'));
128 - $startop->min = 1;
180 + $startop->min = 1;
129 181 $startop->max = 100;
130 - $startop->inputclass = 'small';
131 - $startop->output('start','');
182 + $startop->inputclass = 'small';
183 + $startop->output('start','');
132 184
133 - $endop = new maxField('number');
134 - // $endop->label = __('Normal Opacity','maxbuttons');
185 + $endop = new maxField('number');
186 + // $endop->label = __('Normal Opacity','maxbuttons');
135 187 $endop->name = 'gradient_end_opacity';
136 188 $endop->id = $endop->name;
137 - $endop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_end_opacity') );
189 + $endop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_end_opacity') );
138 190 $endop->setDefault(maxBlocks::getDefault('gradient_end_opacity'));
139 - $endop->min = 1;
191 + $endop->min = 1;
140 192 $endop->max = 100;
141 - $endop->inputclass = 'small';
142 - $endop->output('','end');
143 -
144 - $startop = new maxField('number');
145 - $startop->label = __('Hover opacity','maxbuttons');
193 + $endop->inputclass = 'small';
194 + $endop->conditional = $gradient_conditional;
195 + $endop->output('','end');
196 +
197 + $startop = new maxField('number');
198 + $startop->label = __('Hover opacity','maxbuttons');
146 199 $startop->name = 'gradient_start_opacity_hover';
147 200 $startop->id = $startop->name;
148 - $startop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_start_opacity_hover') );
201 + $startop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_start_opacity_hover') );
149 202 //$startop->setDefault(maxBlocks::getDefault('gradient_start_opacity_hover'));
150 - $startop->min = 1;
203 + $startop->min = 1;
151 204 $startop->max = 100;
152 - $startop->inputclass = 'small';
153 - $startop->output('start','');
205 + $startop->inputclass = 'small';
154 206
155 - $endop = new maxField('number');
156 - // $endop->label = __('Hover Opacity','maxbuttons');
207 + $startop->output('start','');
208 +
209 + $endop = new maxField('number');
210 + // $endop->label = __('Hover Opacity','maxbuttons');
157 211 $endop->name = 'gradient_end_opacity_hover';
158 212 $endop->id = $endop->name;
159 - $endop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_end_opacity_hover') );
213 + $endop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_end_opacity_hover') );
160 214 $endop->setDefault(maxBlocks::getDefault('gradient_end_opacity_hover'));
161 - $endop->min = 1;
215 + $endop->min = 1;
162 216 $endop->max = 100;
163 - $endop->inputclass = 'small';
164 - $endop->output('','end');
217 + $endop->inputclass = 'small';
218 + $endop->conditional = $gradient_conditional;
165 219
220 + $endop->output('','end');
166 221
167 - $stop = new maxField('number');
168 - $stop->label = __('Gradient stop','maxbuttons');
222 +
223 + $stop = new maxField('number');
224 + $stop->label = __('Gradient stop','maxbuttons');
169 225 $stop->name = 'gradient_stop';
170 226 $stop->id = $stop->name;
171 - $stop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_stop') );
227 + $stop->value = maxUtils::strip_px( maxBlocks::getValue('gradient_stop') );
172 228 $stop->setDefault(maxBlocks::getDefault('gradient_stop'));
173 - $stop->min = 1;
229 + $stop->min = 1;
174 230 $stop->max = 99;
175 - $stop->inputclass = 'small';
176 - $stop->output('start','end');
231 + $stop->inputclass = 'small';
232 + $stop->output('start','end');
177 233 ?>
178 -
179 -
180 - </div><!-- // fold -->
181 -
234 +
235 +
236 + </div><!-- // fold -->
237 +
182 238 </div>
183 239 </div>
184 -<?php
240 +<?php
185 241 } // admin_fields
186 242
187 243 } // class
188 244