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/basic.php +381 -340 6.236.28 View file →
@@ -1,118 +1,123 @@
1 1 <?php
2 2 namespace MaxButtons;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 -$blockClass["basic"] = "basicBlock";
6 -$blockOrder[0][] = "basic";
5 +$blockClass["basic"] = "basicBlock";
6 +$blockOrder[0][] = "basic";
7 7
8 -
9 -class basicBlock extends maxBlock
8 +
9 +class basicBlock extends maxBlock
10 10 {
11 - protected $blockname = "basic";
11 + protected $blockname = "basic";
12 12 protected $fields = array("name" => array("default" => ''),
13 - "status" => array("default" => "publish"),
13 + "status" => array("default" => "publish"),
14 14 "description" => array("default" => ''),
15 15 "url" => array("default" => ''),
16 - 'link_title' => array('default' => ''),
17 - // "text" => array("default" => ''),
16 + 'link_title' => array('default' => ''),
17 + // "text" => array("default" => ''),
18 18 "new_window" => array("default" => 0),
19 19 "nofollow" => array("default" => 0)
20 - );
21 - protected $protocols = array("http","https",'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'sms', 'callto', 'fax', 'xmpp', "javascript", 'file'); // allowed url protocols for esc_url functions
22 -
20 + );
21 + protected $protocols = array("http","https",'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'sms', 'callto', 'fax', 'xmpp', "javascript", 'file', 'ms-windows-store', 'steam', 'webcal'); // allowed url protocols for esc_url functions
23 22
23 +
24 24 function __construct()
25 25 {
26 - parent::__construct();
26 + parent::__construct();
27 + $extra_protocols = get_option('maxbuttons_protocol');
28 + $extra_protocols = array_map('trim', array_filter(explode(',', $extra_protocols)));
29 +
30 + if (is_array($extra_protocols) && count($extra_protocols) > 0)
31 + {
32 + $this->protocols = array_merge($this->protocols, $extra_protocols);
33 + }
27 34 }
28 -
29 35
36 +
30 37 public function parse_css($css, $mode = 'normal')
31 38 {
32 39 // emtpy string init is not like by PHP 7.1
33 40 if (! is_array($css))
34 - $css = array();
41 + $css = array();
35 42
36 - $data = $this->data[$this->blockname];
37 -
43 + $data = $this->data[$this->blockname];
44 +
38 45 $css["maxbutton"]["normal"]["position"] = "relative";
39 46 $css["maxbutton"]["normal"]["text-decoration"] = "none";
40 47 // $css["maxbutton"]["normal"]["white-space"] = "nowrap"; // hinders correct rendering of oneline-multilines
41 - $css["maxbutton"]["normal"]["display"] = "inline-block";
48 + $css["maxbutton"]["normal"]["display"] = "inline-block";
42 49
43 - /*if (isset($data["url"]) && $data["url"] == '') // don't show clickable anchor if there is no URL.
50 + /*if (isset($data["url"]) && $data["url"] == '') // don't show clickable anchor if there is no URL.
44 51 {
45 - $css["maxbutton"]["normal"]["cursor"] = 'default';
46 - // $css[":hover"]["cursor"] = 'default';
47 - } */
52 + $css["maxbutton"]["normal"]["cursor"] = 'default';
53 + // $css[":hover"]["cursor"] = 'default';
54 + } */
48 55
49 - return $css;
50 -
56 + return $css;
57 +
51 58 }
52 -
53 59
54 -
55 60 public function save_fields($data, $post)
56 - {
57 - // Possible solution:
61 + {
62 + // Possible solution:
58 63 // $post["url"] = isset($post["url"]) ? urldecode(urldecode($post["url"])) : '';
59 -
60 - $description = false;
61 64
62 - if (isset($post["description"]) && $post["description"] != '')
65 + $description = false;
66 +
67 + if (isset($post["description"]) && $post["description"] != '')
63 68 {
64 - $description = str_replace("\n", '-nwline-', $post["description"]);
65 - $description = sanitize_text_field($description);
66 - $description = str_replace('-nwline-', "\n", $description);
67 -
69 + $description = str_replace("\n", '-nwline-', $post["description"]);
70 + $description = sanitize_text_field($description);
71 + $description = str_replace('-nwline-', "\n", $description);
72 +
68 73 }
69 -
74 +
70 75 $data = parent::save_fields($data, $post);
71 76
72 77 // bypass sanitize for description - causing the end of line-breaks
73 - if ($description)
74 - $data["basic"]["description"] = $description;
75 -
78 + if ($description)
79 + $data["basic"]["description"] = $description;
80 +
76 81 // bypassing sanitize text field - causes problems with URLs and spaces
77 - $url = isset($post["url"]) ? trim($post["url"]) : '';
78 -
79 - $parsed_url = parse_url($url);
80 - $rawEncode = array("query","fragment");
82 + $url = isset($post["url"]) ? trim($post["url"]) : '';
83 +
84 + $parsed_url = parse_url($url);
85 + $rawEncode = array("query","fragment");
81 86 foreach($rawEncode as $item)
82 87 {
83 - if (isset($parsed_url[$item]))
88 + if (isset($parsed_url[$item]))
84 89 {
85 - $parsed_url[$item] = rawurlencode($parsed_url[$item]);
90 + $parsed_url[$item] = rawurlencode($parsed_url[$item]);
86 91 }
87 92 }
88 -
89 - $url = $this->unParseURL($parsed_url);
90 -
91 - $url = str_replace(" ", "%20", trim($url) );
92 -
93 +
94 + $url = $this->unParseURL($parsed_url);
95 +
96 + $url = str_replace(" ", "%20", trim($url) );
97 +
93 98 if (! $this->checkRelative($parsed_url))
94 99 $url = esc_url_raw($url, $this->protocols); // str replace - known WP issue with spaces
95 -
100 +
96 101 $data[$this->blockname]["url"] = $url;
97 -
98 - if (isset($post["name"]))
99 - $data["name"] = sanitize_text_field($post["name"]);
100 - if (isset($post["status"]))
101 - $data["status"] = sanitize_text_field($post["status"]); // for conversion old - new.
102 +
103 + if (isset($post["name"]))
104 + $data["name"] = sanitize_text_field($post["name"]);
105 + if (isset($post["status"]))
106 + $data["status"] = sanitize_text_field($post["status"]); // for conversion old - new.
102 107 return $data;
103 108 }
104 -
109 +
105 110 protected function unparseURL($parsed_url)
106 111 {
107 112 // Don't add // to these schemes
108 - $noslash_schemes = array('javascript', 'mailto', 'tel', 'sms');
113 + $noslash_schemes = array('javascript', 'mailto', 'tel', 'sms');
109 114 if (isset($parsed_url['scheme']) && in_array($parsed_url['scheme'], $noslash_schemes) )
110 115 $scheme = $parsed_url["scheme"] . ":";
111 - else
116 + else
112 117 $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
113 -
114 -
118 +
119 +
115 120 $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
116 121 $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
117 122 $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
118 123 $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
@@ -121,364 +126,400 @@
121 126 $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
122 127 $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
123 128 return "$scheme$user$pass$host$port$path$query$fragment";
124 129 }
125 -
130 +
126 131 /* Check for a relative URL that gets killed by esc_url ( if there is no / first ) */
127 - protected function checkRelative($parsed_url)
132 + protected function checkRelative($parsed_url)
128 133 {
129 134 if (! isset($parsed_url['host']) && ! isset($parsed_url['scheme']) )
130 135 {
131 136 if (isset($parsed_url['path']) && $parsed_url['path'] !== '' && substr($parsed_url['path'], 0,1) !== '/')
132 137 {
133 - return true;
138 + return true;
134 139 }
135 140 }
136 -
137 141 return false;
138 -
139 142 }
140 143
141 144 public function parse_button($domObj, $mode = 'normal')
142 145 {
143 -
144 - $data = $this->data[$this->blockname];
145 - $button_id = $this->data["id"];
146 -
147 - $anchor = $domObj->find("a",0);
148 -
149 - if (isset($data["nofollow"]) && $data["nofollow"] == 1)
150 - $anchor->rel = "nofollow";
151 - // $buttonAttrs[] = "rel=nofollow";
152 - if (isset($data["new_window"]) && $data["new_window"] == 1)
153 - $anchor->target = "_blank";
146 +
147 + $data = $this->data[$this->blockname];
148 + $button_id = $this->data["id"];
149 + $rels = array();
150 +
151 + $anchor = $domObj->find("a",0);
152 +
153 + if (isset($data["nofollow"]) && $data["nofollow"] == 1)
154 + {
155 + $rels[] = 'nofollow';
156 + $rels[] = 'noopener';
157 + }
158 + // $anchor->rel = "nofollow";
159 + // $buttonAttrs[] = "rel=nofollow";
160 +
161 + if (isset($data["new_window"]) && $data["new_window"] == 1)
162 + {
163 + $anchor->target = "_blank";
164 + if (! in_array('noopener', $rels))
165 + $rels[] = 'noopener';
166 + }
154 167 if (isset($data['link_title']) && strlen($data['link_title']) > 0)
155 - $anchor->title = $data['link_title'];
156 -
157 -
158 - if (isset($data["url"]) && $data["url"] != '')
168 + $anchor->title = $data['link_title'];
169 +
170 + $rels = apply_filters('mb/button/rel', $rels);
171 +
172 + if (count($rels) > 0)
159 173 {
160 - $url = $data["url"];
161 - $parsed_url = parse_url($url);
162 -
174 + $anchor->rel = implode(' ', $rels);
175 + }
176 +
177 + if (isset($data["url"]) && $data["url"] != '')
178 + {
179 + $url = $data["url"];
180 + $parsed_url = parse_url($url);
181 +
163 182 if (! $this->checkRelative($parsed_url))
164 183 $url = esc_url($url, $this->protocols);
165 -
184 +
166 185 $url = rawurldecode($url); // removes the + from a URL part.
167 - $url = apply_filters('mb-url', $url, $data['url']); // passes processed url / raw url.
168 - $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
169 -
170 -
186 + $url = apply_filters('mb-url', $url, $data['url']); // passes processed url / raw url.
187 + $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
188 +
189 +
171 190 $anchor->href = $url;
172 - //do_shortcode( esc_url($url, $this->protocols) );
173 -
191 + //do_shortcode( esc_url($url, $this->protocols) );
192 +
174 193 }
175 - else // fixing an iOS problem which renders anchors without URL wrongly.
194 + else // fixing an iOS problem which renders anchors without URL wrongly.
176 195 {
177 196 $anchor->href = 'javascript:void(0);';
178 - }
179 -
180 -
181 - return $domObj;
182 -
183 - }
197 + }
184 198
199 +
200 + return $domObj;
201 +
202 + }
203 +
185 204 public function map_fields($map)
186 205 {
187 -
188 - $map["url"]["attr"] = "href";
189 - $map["link_title"]["attr"] = "title";
190 -
191 -// $map["text"]["func"] = "updateAnchorText";
192 -
193 - return $map;
206 +
207 + $map["url"]["attr"] = "href";
208 + $map["link_title"]["attr"] = "title";
209 +
210 +// $map["text"]["func"] = "updateAnchorText";
211 +
212 + return $map;
194 213 }
195 214
196 - public function admin_fields()
215 + public function admin_fields()
197 216 {
198 - //parent::admin_fields();
199 -
200 - //$data = $this->data[$this->blockname];
201 - // On it's way out this
202 - /*foreach($this->fields as $field => $options)
203 - {
204 - $default = (isset($options["default"])) ? $options["default"] : '';
205 - ${$field} = (isset($data[$field])) ? $data[$field] : $default;
206 -
207 - } */
208 - $icon_url = MB()->get_plugin_url() . 'images/icons/' ;
217 +
218 + $icon_url = MB()->get_plugin_url() . 'images/icons/';
219 + $admin = MB()->getClass('admin');
209 220 ?>
210 221
211 222 <div class="mb_tab option-container mb_tab">
212 223 <div class="title"><?php _e('Basics', 'maxbuttons') ?></div>
213 224 <div class="inside basic">
214 - <?php
215 -
225 + <?php
226 + $color_copy_self = __("Replace color from other field", "maxbuttons");
227 + $color_copy_move = __("Copy Color to other field", "maxbuttons");
228 +
216 229 // Name
217 - $field_name = new maxField() ;
218 - $field_name->label = __('Button Name', 'maxbuttons');
230 + $field_name = new maxField() ;
231 + $field_name->label = __('Button Name', 'maxbuttons');
219 232 // $field_name->note = __('Something that you can quickly identify the button with.', 'maxbuttons');
220 - $field_name->value = maxBlocks::getValue('name');
221 - $field_name->id = 'name';
222 - $field_name->name = $field_name->id;
223 - $field_name->placeholder = __("Button Name","maxbuttons");
224 - $field_name->output('start','end');
225 -
226 -
227 - // URL
228 - $field_url = new maxField();
233 + $field_name->value = maxBlocks::getValue('name');
234 + $field_name->id = 'name';
235 + $field_name->name = $field_name->id;
236 + $field_name->placeholder = __("Button Name","maxbuttons");
237 + // $field_name->output('start','end');
238 +
239 + $admin->addField($field_name, 'start', 'end');
240 +
241 + // URL
242 + $field_url = new maxField();
229 243 $field_url->label = __('URL', 'maxbuttons');
230 244 // $field_url->note = __('The link when the button is clicked.', 'maxbuttons');
231 245 $field_url->value = rawurldecode(maxBlocks::getValue('url') );
232 - $field_url->id = 'url';
233 - $field_url->placeholder = __("http://","maxbuttons");
234 - $field_url->name = $field_url->id;
235 -
236 - $field_url->output('start','end');
237 -
246 + $field_url->id = 'url';
247 + $field_url->placeholder = __("http://","maxbuttons");
248 + $field_url->name = $field_url->id;
249 +
250 + //$field_url->output('start','end');
251 + $admin->addField($field_url,'start', 'end');
252 +
238 253 // Spacer
239 - $fspacer = new maxField('spacer');
240 - $fspacer->name = 'url_options';
254 + $fspacer = new maxField('spacer');
255 + $fspacer->name = 'url_options';
241 256 $fspacer->label = '&nbsp;';
242 - $fspacer->output('start');
243 -
244 -
257 + // $fspacer->output('start');
258 +
259 + $admin->addField($fspacer, 'start');
260 +
245 261 // New Window
246 - $fwindow = new maxField('checkbox');
247 - $fwindow->label = __('Open in New Window', 'maxbuttons');
248 - $fwindow->name = 'new_window';
249 - $fwindow->id = $fwindow->name;
262 + $fwindow = new maxField('checkbox');
263 + $fwindow->label = __('Open in New Window', 'maxbuttons');
264 + $fwindow->name = 'new_window';
265 + $fwindow->id = $fwindow->name;
250 266 $fwindow->value = 1;
251 - //$fwindow->inputclass = 'check_button';
252 - $fwindow->checked = checked( maxBlocks::getValue('new_window'), 1, false);
253 -
254 - $fwindow->output('','');
255 -
256 - //$fspacer->name ='rel_options';
257 - //$fspacer->output('start');
258 -
259 - // NoRel
260 - $ffollow = new maxField('checkbox');
267 + //$fwindow->inputclass = 'check_button';
268 + $fwindow->checked = checked( maxBlocks::getValue('new_window'), 1, false);
269 +
270 + //$fwindow->output('','');
271 + $admin->addField($fwindow);
272 +
273 + // NoRel
274 + $ffollow = new maxField('checkbox');
261 275 $ffollow->label = __('Use rel="nofollow"', 'maxbuttons');
262 - $ffollow->value = 1;
263 - $ffollow->name = 'nofollow';
264 - $ffollow->id = $ffollow->name;
265 - $ffollow->checked = checked( maxBlocks::getValue('nofollow'), 1, false);
266 -
267 - $ffollow->output('','end');
268 -
276 + $ffollow->value = 1;
277 + $ffollow->name = 'nofollow';
278 + $ffollow->id = $ffollow->name;
279 + $ffollow->checked = checked( maxBlocks::getValue('nofollow'), 1, false);
280 +
281 + //$ffollow->output('','end');
282 + $admin->addField($ffollow, '','end');
269 283 // TITLE
270 -
284 +
271 285 $field_title = new maxField();
272 - $field_title->label = __('Button Title', 'maxbuttons');
286 + $field_title->label = __('Button Tooltip', 'maxbuttons');
273 287 $field_title->name = 'link_title'; // title is too generic
274 - $field_title->id = $field_title->name;
275 - $field_title->value = maxBlocks::getValue('link_title');
276 -
277 - $field_title->output('start','end');
278 -
279 - // TEXT
280 - $field_text = new maxField();
281 - $field_text->label = __('Text','maxbuttons');
282 - $field_text->name = 'text';
283 - $field_text->id = 'text';
288 + $field_title->id = $field_title->name;
289 + $field_title->value = maxBlocks::getValue('link_title');
290 +
291 + //$field_title->output('start','end');
292 + $admin->addField($field_title, 'start', 'end');
293 +
294 + // TEXT
295 + $field_text = new maxField();
296 + $field_text->label = __('Text','maxbuttons');
297 + $field_text->name = 'text';
298 + $field_text->id = 'text';
284 299 $field_text->value = maxBlocks::getValue('text') ;
285 -
286 - $field_text->output('start','end');
287 -
300 +
301 + // $field_text->output('start','end');
302 + $admin->addField($field_text, 'start', 'end');
303 +
288 304 // FONTS
289 - $fonts = MB()->getClass('admin')->loadFonts();
290 -
291 - $field_font = new maxField('generic');
292 - $field_font->label = __('Font','maxbuttons');
293 - $field_font->name = 'font';
294 - $field_font->id = $field_font->name;
295 - $field_font->value= maxBlocks::getValue('font');
296 - $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
297 -
298 - $field_font->output('start');
305 + $fonts = MB()->getClass('admin')->loadFonts();
306 +
307 + $field_font = new maxField('generic');
308 + $field_font->label = __('Font','maxbuttons');
309 + $field_font->name = 'font';
310 + $field_font->id = $field_font->name;
311 + $field_font->value= maxBlocks::getValue('font');
312 + $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
313 +
314 + //$field_font->output('start');
315 + $admin->addField($field_font,'start');
299 316 ?>
300 317
301 - <?php
318 + <?php
302 319 // FONT SIZE
303 - //global $maxbuttons_font_sizes;
304 - $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
305 -
306 -
307 - $field_size = new maxField('number');
308 - // $field_size->label = '';
309 - $field_size->name = 'font_size';
320 + //global $maxbuttons_font_sizes;
321 + $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
322 +
323 +
324 + $field_size = new maxField('number');
325 + // $field_size->label = '';
326 + $field_size->name = 'font_size';
310 327 $field_size->id= $field_size->name;
311 - $field_size->inputclass = 'tiny';
312 - $field_size->min = 8;
313 - $field_size->value = maxUtils::strip_px(maxBlocks::getValue('font_size'));
314 - //$field_size->content = maxUtils::selectify($field_size->name, $sizes, $field_size->value, '', 'small');
315 -
316 - $field_size->output();
328 + $field_size->inputclass = 'tiny';
329 + $field_size->min = 8;
330 + $field_size->value = maxUtils::strip_px(maxBlocks::getValue('font_size'));
331 + //$field_size->content = maxUtils::selectify($field_size->name, $sizes, $field_size->value, '', 'small');
317 332
333 + //$field_size->output();
334 + $admin->addField($field_size);
335 +
318 336 // Font style checkboxes
319 - $fweight = new maxField('checkbox');
320 - $fweight->icon = 'dashicons-editor-bold';
337 + $fweight = new maxField('checkbox');
338 + $fweight->icon = 'dashicons-editor-bold';
321 339 $fweight->title = __("Bold",'maxbuttons');
322 - $fweight->id = 'check_fweight';
323 - $fweight->name = 'font_weight';
324 - $fweight->value = 'bold';
340 + $fweight->id = 'check_fweight';
341 + $fweight->name = 'font_weight';
342 + $fweight->value = 'bold';
325 343 $fweight->inputclass = 'check_button icon';
326 344 $fweight->checked = checked( maxBlocks::getValue('font_weight'), 'bold', false);
327 -
328 - $fweight->output('group_start');
329 -
330 - $fstyle = new maxField('checkbox');
331 - $fstyle->icon = 'dashicons-editor-italic';
345 +
346 + // $fweight->output('group_start');
347 + $admin->addField($fweight, 'group_start');
348 +
349 + $fstyle = new maxField('checkbox');
350 + $fstyle->icon = 'dashicons-editor-italic';
332 351 $fstyle->title = __("Italic",'maxbuttons');
333 - $fstyle->id = 'check_fstyle';
334 - $fstyle->name = 'font_style';
335 - $fstyle->value = 'italic';
336 - $fstyle->inputclass = 'check_button icon';
352 + $fstyle->id = 'check_fstyle';
353 + $fstyle->name = 'font_style';
354 + $fstyle->value = 'italic';
355 + $fstyle->inputclass = 'check_button icon';
337 356 $fstyle->checked = checked( maxBlocks::getValue('font_style'), 'italic', false);
338 -
339 - $fstyle->output('','group_end');
340 -
341 -
342 - $falign_left = new maxField('radio');
343 - $falign_left->icon = 'dashicons-editor-alignleft';
344 - $falign_left->title = __('Align left','maxbuttons');
345 - $falign_left->id = 'radio_talign_left';
346 - $falign_left->name = 'text_align';
347 - $falign_left->value = 'left';
348 - $falign_left->inputclass = 'check_button icon';
349 - $falign_left->checked = checked ( maxblocks::getValue('text_align'), 'left', false);
350 -
351 - $falign_left->output('group_start');
352 357
353 - $falign_center = new maxField('radio');
354 - $falign_center->icon = 'dashicons-editor-aligncenter';
355 - $falign_center->title = __('Align center','maxbuttons');
356 - $falign_center->id = 'radio_talign_center';
357 - $falign_center->name = 'text_align';
358 - $falign_center->value = 'center';
359 - $falign_center->inputclass = 'check_button icon';
360 - $falign_center->checked = checked( maxblocks::getValue('text_align'), 'center', false);
361 -
362 - $falign_center->output();
358 + //$fstyle->output('','group_end');
359 + $admin->addField($fstyle, '', 'group_end');
363 360
364 - $falign_right = new maxField('radio');
365 - $falign_right->icon = 'dashicons-editor-alignright';
366 - $falign_right->title = __('Align right','maxbuttons');
367 - $falign_right->id = 'radio_talign_right';
368 - $falign_right->name = 'text_align';
369 - $falign_right->value = 'right';
370 - $falign_right->inputclass = 'check_button icon';
371 - $falign_right->checked = checked( maxblocks::getValue('text_align'), 'right', false);
372 -
373 - $falign_right->output('', array('group_end','end') );
374 -
361 + $falign_left = new maxField('radio');
362 + $falign_left->icon = 'dashicons-editor-alignleft';
363 + $falign_left->title = __('Align left','maxbuttons');
364 + $falign_left->id = 'radio_talign_left';
365 + $falign_left->name = 'text_align';
366 + $falign_left->value = 'left';
367 + $falign_left->inputclass = 'check_button icon';
368 + $falign_left->checked = checked ( maxblocks::getValue('text_align'), 'left', false);
369 +
370 + //$falign_left->output('group_start');
371 + $admin->addField($falign_left, 'group_start');
372 +
373 + $falign_center = new maxField('radio');
374 + $falign_center->icon = 'dashicons-editor-aligncenter';
375 + $falign_center->title = __('Align center','maxbuttons');
376 + $falign_center->id = 'radio_talign_center';
377 + $falign_center->name = 'text_align';
378 + $falign_center->value = 'center';
379 + $falign_center->inputclass = 'check_button icon';
380 + $falign_center->checked = checked( maxblocks::getValue('text_align'), 'center', false);
381 +
382 + //$falign_center->output();
383 + $admin->addField($falign_center);
384 +
385 + $falign_right = new maxField('radio');
386 + $falign_right->icon = 'dashicons-editor-alignright';
387 + $falign_right->title = __('Align right','maxbuttons');
388 + $falign_right->id = 'radio_talign_right';
389 + $falign_right->name = 'text_align';
390 + $falign_right->value = 'right';
391 + $falign_right->inputclass = 'check_button icon';
392 + $falign_right->checked = checked( maxblocks::getValue('text_align'), 'right', false);
393 +
394 + //$falign_right->output('', array('group_end','end') );
395 + $admin->addField($falign_right, '', array('group_end','end') );
396 +
375 397 // Padding - trouble
376 - $ptop = new maxField('number');
377 - $ptop->label = __('Padding', 'maxbuttons');
398 + $ptop = new maxField('number');
399 + $ptop->label = __('Padding', 'maxbuttons');
378 400 $ptop->id = 'padding_top';
379 - $ptop->name = $ptop->id;
380 - $ptop->min = 0;
401 + $ptop->name = $ptop->id;
402 + $ptop->min = 0;
381 403 $ptop->inputclass = 'tiny';
382 - $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >';
383 - $ptop->value = maxUtils::strip_px(maxBlocks::getValue('padding_top'));
384 -
385 - $ptop->output('start');
386 -
387 - $pright = new maxField('number');
404 + $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >';
405 + $ptop->value = maxUtils::strip_px(maxBlocks::getValue('padding_top'));
406 +
407 + //$ptop->output('start');
408 + $admin->addField($ptop,'start');
409 +
410 + $pright = new maxField('number');
388 411 $pright->id = 'padding_right';
389 - $pright->name = $pright->id;
412 + $pright->name = $pright->id;
390 413 $pright->min = 0;
391 - $pright->inputclass = 'tiny';
392 - $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >';
393 - $pright->value = maxUtils::strip_px(maxBlocks::getValue('padding_right'));
394 -
395 - $pright->output();
414 + $pright->inputclass = 'tiny';
415 + $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >';
416 + $pright->value = maxUtils::strip_px(maxBlocks::getValue('padding_right'));
396 417
397 - $pbottom = new maxField('number');
418 + //$pright->output();
419 + $admin->addField($pright);
420 +
421 + $pbottom = new maxField('number');
398 422 $pbottom->id = 'padding_bottom';
399 - $pbottom->name = $pbottom->id;
400 - $pbottom->min = 0;
401 - $pbottom->inputclass = 'tiny';
402 - $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >';
403 - $pbottom->value = maxUtils::strip_px(maxBlocks::getValue('padding_bottom'));
404 -
405 - $pbottom->output();
406 -
407 - $pleft = new maxField('number');
423 + $pbottom->name = $pbottom->id;
424 + $pbottom->min = 0;
425 + $pbottom->inputclass = 'tiny';
426 + $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >';
427 + $pbottom->value = maxUtils::strip_px(maxBlocks::getValue('padding_bottom'));
428 +
429 + //$pbottom->output();
430 + $admin->addField($pbottom);
431 +
432 + $pleft = new maxField('number');
408 433 $pleft->id = 'padding_left';
409 - $pleft->name = $pleft->id;
410 - $pleft->min = 0;
411 - $pleft->inputclass = 'tiny';
412 - $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >';
413 - $pleft->value = maxUtils::strip_px(maxBlocks::getValue('padding_left'));
414 -
415 - $pleft->output('','end');
416 -
417 -
434 + $pleft->name = $pleft->id;
435 + $pleft->min = 0;
436 + $pleft->inputclass = 'tiny';
437 + $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >';
438 + $pleft->value = maxUtils::strip_px(maxBlocks::getValue('padding_left'));
439 +
440 + //$pleft->output('','end');
441 + $admin->addField($pleft,'', 'end');
442 +
443 +
418 444 // Text Color
419 - $fcolor = new maxField('color');
420 - $fcolor->id = 'text_color';
421 - $fcolor->name = $fcolor->id;
422 - $fcolor->value = maxBlocks::getColorValue('text_color');
423 - $fcolor->label = __('Text Color','maxbuttons');
424 - $fcolor->copycolor = true;
425 - $fcolor->bindto = 'text_color_hover';
426 - $fcolor->copypos = 'right';
427 - $fcolor->output('start');
428 -
429 - // Text Color Hover
430 - $fcolor_hover = new maxField('color');
431 - $fcolor_hover->id = 'text_color_hover';
432 - $fcolor_hover->name = $fcolor_hover->id;
433 - $fcolor_hover->value = maxBlocks::getColorValue('text_color_hover');
434 - $fcolor_hover->label = __('Text Color Hover','maxbuttons');
435 - $fcolor_hover->copycolor = true;
436 - $fcolor_hover->bindto = $fcolor->id;
437 - $fcolor_hover->copypos = 'left';
438 - $fcolor_hover->output('','end');
439 -
440 - // Dimension : width
441 - $field_width = new maxField('number');
442 - $field_width->label = __('Button Width','maxbuttons');
443 - $field_width->name = 'button_width';
444 - $field_width->id = $field_width->name;
445 - $field_width->inputclass = 'small';
445 + $fcolor = new maxField('color');
446 + $fcolor->id = 'text_color';
447 + $fcolor->name = $fcolor->id;
448 + $fcolor->value = maxBlocks::getColorValue('text_color');
449 + $fcolor->label = __('Text Color','maxbuttons');
450 + $fcolor->copycolor = true;
451 + $fcolor->bindto = 'text_color_hover';
452 + $fcolor->copypos = 'right';
453 + $fcolor->right_title = $color_copy_move;
454 + $fcolor->left_title = $color_copy_self;
455 +
456 + // $fcolor->output('start');
457 + $admin->addField($fcolor, 'start');
458 +
459 + // Text Color Hover
460 + $fcolor_hover = new maxField('color');
461 + $fcolor_hover->id = 'text_color_hover';
462 + $fcolor_hover->name = $fcolor_hover->id;
463 + $fcolor_hover->value = maxBlocks::getColorValue('text_color_hover');
464 + $fcolor_hover->label = __('Text Color Hover','maxbuttons');
465 + $fcolor_hover->copycolor = true;
466 + $fcolor_hover->bindto = $fcolor->id;
467 + $fcolor_hover->copypos = 'left';
468 + $fcolor_hover->right_title = $color_copy_self;
469 + $fcolor_hover->left_title = $color_copy_move;
470 + //$fcolor_hover->output('','end');
471 +
472 + $admin->addField($fcolor_hover, '','end');
473 +
474 + // Dimension : width
475 + $field_width = new maxField('number');
476 + $field_width->label = __('Button Width','maxbuttons');
477 + $field_width->name = 'button_width';
478 + $field_width->id = $field_width->name;
479 + $field_width->inputclass = 'small';
446 480 $field_width->min = 0;
447 - $field_width->value= maxUtils::strip_px(maxBlocks::getValue('button_width')); // strippx?
448 - $field_width->output('start');
449 -
450 - // Dimension : height
451 - $field_height = new maxField('number');
452 - $field_height->label = __('Button Height','maxbuttons');
453 - $field_height->name = 'button_height';
454 - $field_height->id = $field_height->name;
455 - $field_height->inputclass = 'small';
481 + $field_width->value= maxUtils::strip_px(maxBlocks::getValue('button_width')); // strippx?
482 + //$field_width->output('start');
483 +
484 + $admin->addField($field_width, 'start');
485 +
486 + // Dimension : height
487 + $field_height = new maxField('number');
488 + $field_height->label = __('Button Height','maxbuttons');
489 + $field_height->name = 'button_height';
490 + $field_height->id = $field_height->name;
491 + $field_height->inputclass = 'small';
456 492 $field_height->min = 0;
457 - $field_height->value= maxUtils::strip_px(maxBlocks::getValue('button_height')); // strippx?
458 - $field_height->output('','end');
459 -
493 + $field_height->value= maxUtils::strip_px(maxBlocks::getValue('button_height')); // strippx?
494 + //$field_height->output('','end');
495 +
496 + $admin->addField($field_height, '', 'end');
497 +
460 498 // Description
461 - $description_hide = get_option('maxbuttons_hidedescription');
462 - if ($description_hide == 1)
463 - $field_desc = new maxField('hidden');
499 + $description_hide = get_option('maxbuttons_hidedescription');
500 + if ($description_hide == 1)
501 + $field_desc = new maxField('hidden');
464 502 else
465 - $field_desc = new maxField('textarea');
466 -
503 + $field_desc = new maxField('textarea');
504 +
467 505 $field_desc->label = __('Description', 'maxbuttons');
468 - $field_desc->name = 'description';
469 - $field_desc->id = $field_desc->name;
470 - $field_desc->esc_function = 'esc_textarea';
471 - $field_desc->value = maxBlocks::getValue('description') ;
472 - $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons');
473 - $field_desc->output('start','end');
474 -
475 - ?>
476 -
506 + $field_desc->name = 'description';
507 + $field_desc->id = $field_desc->name;
508 + $field_desc->esc_function = 'esc_textarea';
509 + $field_desc->value = maxBlocks::getValue('description') ;
510 + $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons');
511 + //$field_desc->output('start','end');
477 512
513 + $admin->addField($field_desc, 'start', 'end');
514 +
515 + $admin->display_fields();
516 + ?>
517 +
518 +
478 519 </div>
479 520 </div>
480 521 <?php } // admin_display
481 -
482 - } // class
483 -
522 +
523 + } // class
524 +
484 525 ?>