PluginProbe
MaxButtons – Create buttons / 9.8.2
MaxButtons – Create buttons v9.8.2
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
maxbuttons / blocks / basic.php

basic.php in MaxButtons – Create buttons 9.8.2, at blocks/basic.php

663 lines 24.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace MaxButtons;
5 defined('ABSPATH') or die('No direct access permitted');
6
7 $blockClass["basic"] = "basicBlock";
8 $blockOrder[10][] = "basic";
9
10 class basicBlock extends maxBlock
11 {
12 protected $blockname = "basic";
13 protected $fields = array("name" => array("default" => ''),
14 "status" => array("default" => "publish"),
15 "description" => array("default" => ''),
16 "url" => array("default" => ''),
17 'link_title' => array('default' => ''),
18 // "text" => array("default" => ''),
19 "new_window" => array("default" => '0'),
20 "nofollow" => array("default" => '0'),
21 'is_download' => array('default'=> '0'),
22 );
23 protected $protocols;
24
25 public function __construct()
26 {
27 parent::__construct();
28
29 $this->protocols = maxUtils::getAllowedProcotols();
30 }
31
32 public function parse_css($css, $screens, string $mode = 'normal')
33 {
34 // emtpy string init is not like by PHP 7.1
35
36 if (! is_array($css))
37 $css = array();
38
39 $data = $this->getBlockData();
40
41 $css["maxbutton"]["normal"]["position"] = "relative";
42 $css["maxbutton"]["normal"]["text-decoration"] = "none";
43 // $css["maxbutton"]["normal"]["white-space"] = "nowrap"; // hinders correct rendering of oneline-multilines
44 $css["maxbutton"]["normal"]["display"] = "inline-block";
45 $css["maxbutton"]["normal"]["vertical-align"] = 'middle';
46 //$css["maxbutton"]["normal"]["overflow"] = "hidden"; // hinder tooltip
47
48
49 // option to show border boxed buttons in preview area.
50 $border_box = get_option('maxbuttons_borderbox');
51
52 if ($border_box == 1)
53 {
54 $css['maxbutton']['normal']['box-sizing'] = 'border-box';
55 }
56
57 $css = parent::parse_css($css, $screens, $mode);
58
59
60 return $css;
61
62 }
63
64 public function save_fields($data, $post, $screens)
65 {
66 // Possible solution:
67 // $post["url"] = isset($post["url"]) ? urldecode(urldecode($post["url"])) : '';
68
69 $description = false;
70
71 if (isset($post["description"]) && $post["description"] != '')
72 {
73 $description = str_replace("\n", '-nwline-', $post["description"]);
74 $description = sanitize_text_field($description);
75 $description = str_replace('-nwline-', "\n", $description);
76 }
77
78 $data = parent::save_fields($data, $post, $screens);
79
80 // bypass sanitize for description - causing the end of line-breaks
81 if ($description)
82 $data["basic"]["description"] = $description;
83
84 // bypassing sanitize text field - causes problems with URLs and spaces
85 $url = isset($post["url"]) ? trim($post["url"]) : '';
86
87 // filter zero width space ( https://en.wikipedia.org/wiki/Zero-width_space ) in URL
88 // https://stackoverflow.com/questions/22600235/remove-unicode-zero-width-space-php
89 $url = str_replace("&#8203;", "", $url);
90 $url = str_replace("\xE2\x80\x8C", "", $url);
91 $url = str_replace("\xE2\x80\x8B", "", $url);
92
93 $parsed_url = parse_url($url);
94
95 $rawEncode = array("query","fragment");
96 foreach($rawEncode as $item)
97 {
98 if (isset($parsed_url[$item]))
99 {
100 $parsed_url[$item] = rawurlencode($parsed_url[$item]);
101 }
102 }
103
104 $url = $this->unParseURL($parsed_url);
105
106 $url = str_replace(" ", "%20", trim($url) );
107
108 if (! $this->checkRelative($parsed_url))
109 $url = esc_url_raw($url, $this->protocols); // str replace - known WP issue with spaces
110
111 $data[$this->blockname]["url"] = $url;
112
113 if (isset($post["name"]))
114 $data["name"] = sanitize_text_field($post["name"]);
115 if (isset($post["status"]))
116 $data["status"] = sanitize_text_field($post["status"]); // for conversion old - new.
117 return $data;
118 }
119
120 protected function unparseURL($parsed_url)
121 {
122 // Don't add // to these schemes
123 $noslash_schemes = array('javascript', 'mailto', 'tel', 'sms');
124 if (isset($parsed_url['scheme']) && in_array($parsed_url['scheme'], $noslash_schemes) )
125 $scheme = $parsed_url["scheme"] . ":";
126 else
127 $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
128
129 $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
130 $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
131 $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
132 $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
133 $pass = ($user || $pass) ? "$pass@" : '';
134 $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
135 $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
136 $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
137 return "$scheme$user$pass$host$port$path$query$fragment";
138 }
139
140 /* Check for a relative URL that gets killed by esc_url ( if there is no / first ) */
141 protected function checkRelative($parsed_url)
142 {
143 if (! isset($parsed_url['host']) && ! isset($parsed_url['scheme']) )
144 {
145 if (isset($parsed_url['path']) && $parsed_url['path'] !== '' && substr($parsed_url['path'], 0,1) !== '/')
146 {
147 return true;
148 }
149 }
150 return false;
151 }
152
153 public function parse_button($domObj, $mode = 'normal')
154 {
155
156 $data = $this->getBlockData();
157 $button_id = $this->data["id"];
158 $rels = array();
159
160 $anchor = $domObj->find("a",0);
161
162 if (isset($data["nofollow"]) && $data["nofollow"] == 1)
163 {
164 $rels[] = 'nofollow';
165 $rels[] = 'noopener';
166 }
167
168 if (isset($data["new_window"]) && $data["new_window"] == 1)
169 {
170 $anchor->target = "_blank";
171 if (! in_array('noopener', $rels))
172 $rels[] = 'noopener';
173 }
174 if (isset($data['link_title']) && strlen($data['link_title']) > 0)
175 $anchor->title = esc_attr($data['link_title']);
176
177 $rels = apply_filters('mb/button/rel', $rels);
178
179 if (count($rels) > 0)
180 {
181 $anchor->rel = esc_attr(implode(' ', $rels));
182 }
183
184 if (isset($data["url"]) && $data["url"] != '')
185 {
186 $url = $data["url"];
187
188 $parsed_url = parse_url($url);
189
190 if (false === $this->checkRelative($parsed_url))
191 {
192 $url = esc_url($url, $this->protocols);
193 }
194
195 if (false === apply_filters('mb/use_unsafe_js/', false))
196 {
197 $url = wp_strip_all_tags($url);
198 $url = str_replace('javascript:', '', $url);
199 }
200
201
202
203 $url = rawurldecode($url); // removes the + from a URL part.
204 $url = apply_filters('mb-url', $url, $data['url']); // passes processed url / raw url.
205 $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
206
207 // This esc_attr is security and can't be removed - even if some urls fail with it.
208 $anchor->href = esc_attr($url);
209
210 }
211 else // fixing an iOS problem which renders anchors without URL wrongly.
212 {
213 $anchor->href = 'javascript:void(0);';
214 }
215
216 if (isset($data['is_download']) && $data['is_download'] == 1)
217 {
218 $anchor->download = '';
219 }
220
221
222 return $domObj;
223
224 }
225
226 public function map_fields($map)
227 {
228 $map = parent::map_fields($map);
229
230 $map["url"]["attr"] = "href";
231 $map["link_title"]["attr"] = "title";
232
233 return $map;
234 }
235
236 public function check_unique_name($name)
237 {
238 global $wpdb;
239 $table = maxUtils::get_table_name();
240
241 $button_id = $this->data['id'];
242
243 if ($name === false || strlen($name) == 0 || $name == '')
244 return false;
245
246 if ($button_id <= 0)
247 return false;
248
249 $sql = $wpdb->prepare("SELECT id from $table where name = %s and status = 'publish' and id <> %d ", $name, $button_id);
250
251 $results = $wpdb->get_col($sql);
252
253 if (count($results) > 0)
254 {
255 $message = __('Button name already used. Using non-unique names with the shortcode can cause issues', 'maxbuttons');
256 $message .= ' ' . __('Already used in : ');
257 foreach($results as $id)
258 {
259 $url = admin_url() . 'admin.php?page=maxbuttons-controller&action=edit&id=' . $id;
260 $message .= ' <a href="' . esc_attr($url) . '" target="_blank">' . intval($id) . '</a> ';
261 }
262
263 return $message;
264 }
265 }
266
267 public function admin_fields($screen)
268 {
269
270 $icon_url = MB()->get_plugin_url() . 'images/icons/';
271
272 $start_block = new maxField('block_start');
273 $start_block->name = __('basic', 'maxbuttons');
274 $start_block->label = __('Basics', 'maxbuttons');
275 $screen->addField($start_block);
276
277 $color_copy_self = __("Replace color from other field", "maxbuttons");
278 $color_copy_move = __("Copy Color to other field", "maxbuttons");
279
280 $check_name = $this->check_unique_name($screen->getValue('name'));
281
282 // Name
283 $field_name = new maxField();
284 $field_name->label = __('Button Name', 'maxbuttons');
285 $field_name->id = $screen->getFieldID('name');
286 $field_name->value = $screen->getValue($field_name->id);
287 $field_name->name = $field_name->id;
288 $field_name->is_responsive = false;
289 $field_name->placeholder = __("Button Name","maxbuttons");
290 $field_name->help = __('<p>Internal name for button. Specify purpose or use. Additional info can be added to description.</p> <p>You can use button name in the shortcode <br> [maxbutton name="button-name"] </p>
291 <p class="shortcode"> Shortcode attribute : name </p>', 'maxbuttons');
292
293 if ($check_name)
294 {
295 $field_name->warning = $check_name;
296 //$field_name->error = $check_name;
297 }
298 $screen->addField($field_name, 'start', 'end');
299
300 // URL
301 $field_url = new maxField();
302 $field_url->label = __('URL', 'maxbuttons');
303 // $field_url->note = __('The link when the button is clicked.', 'maxbuttons');
304 $field_url->id = $screen->getFieldID('url');
305
306 $the_url = $screen->getValue($field_url->id);
307 if (false !== $the_url)
308 {
309 $the_url = rawurldecode($the_url);
310 }
311 $field_url->value = $the_url;
312 $field_url->placeholder = __("http://","maxbuttons");
313 $field_url->name = $field_url->id;
314 $field_url->is_responsive = false;
315 $field_url->help = __("<p>Enter any URL you wish to link to. Use 'Select Site Content' button to search in your pages, posts and media </p>
316 <p>Examples: <br><ul class='nowrap'><li> https://example.com/ </li>
317 <li> /local-page/ </li>
318 <li> javascript:window.history.back(); </li></ul></p>
319 <p class='shortcode'> Shortcode attribute : url </p>", 'maxbuttons');
320 $screen->addField($field_url,'start');
321
322 $url_button = new maxField('button');
323 $url_button->id = $screen->getFieldID('url_button');
324 $url_button->name = $url_button->id;
325 $url_button->button_label = __('Select Site Content', 'maxbuttons');
326 $url_button->is_responsive = false;
327 $screen->addField($url_button, '', 'end');
328
329
330 if (isset($_GET['copied']))
331 {
332 $copyno = new maxField('generic');
333 $copyno->label = '&nbsp;';
334 $copyno->name = 'prevent-copy-message';
335 $copyno->content = "<p>" . __('<strong>Tip: </strong> You don\'t need to copy buttons to change URL or Text. See the examples on top of page') . '</p>';
336 $screen->addField($copyno, 'start','end');
337 }
338
339 $url_nonce = new maxField('hidden');
340 $url_nonce->id = $screen->getFieldID('_ajax_linking_nonce');
341 $url_nonce->name = $url_nonce->id;
342 $url_nonce->value = wp_create_nonce('internal-linking');
343 $url_nonce->is_responsive = false;
344
345 $screen->addField($url_nonce);
346
347 // Spacer
348 $fspacer = new maxField('spacer');
349 $fspacer->name = 'url_options';
350 $fspacer->label = '&nbsp;';
351 $fspacer->is_responsive = false;
352 $screen->addField($fspacer, 'start');
353
354 // New Window
355 $fwindow = new maxField('switch');
356 $fwindow->label_after = __('Open in New Tab', 'maxbuttons');
357 $fwindow->id = $screen->getFieldID('new_window');
358 $fwindow->name = $fwindow->id;
359 $fwindow->value = 1;
360 $fwindow->is_responsive = false;
361 $fwindow->input_class = 'small';
362 $fwindow->checked = checked( $screen->getValue($fwindow->id), 1, false);
363 $screen->addField($fwindow, '', '');
364
365 // NoRel
366 // $screen->addField($fspacer, 'start');
367 $ffollow = new maxField('switch');
368 $ffollow->label_after = __('Use rel="nofollow"', 'maxbuttons');
369 $ffollow->value = 1;
370 $ffollow->id = $screen->getFieldID('nofollow');
371 $ffollow->name = $ffollow->id;
372 $ffollow->is_responsive = false;
373 $ffollow->input_class = 'small';
374 $ffollow->checked = checked( $screen->getValue($ffollow->id), 1, false);
375 $screen->addField($ffollow, '','end');
376 // TITLE
377
378 $screen->addField($fspacer, 'start');
379 $fdownload = new MaxField('switch');
380 $fdownload->label_after = __('URL is download', 'maxbuttons');
381 $fdownload->value = 1;
382 $fdownload->id = $screen->getFieldID('is_download');
383 $fdownload->name = $fdownload->id;
384 $fdownload->is_responsive = false;
385 $fdownload->input_class = 'small';
386 $fdownload->checked = checked($screen->getValue($fdownload->id), 1, false);
387 $fdownload->help = __('This will tell the browser to download the URL', 'maxbuttons');
388 $screen->addField($fdownload, '', 'end');
389
390 $field_title = new maxField();
391 $field_title->label = __('Button Tooltip', 'maxbuttons');
392 $field_title->id = $screen->getFieldID('link_title');
393 $field_title->name = $field_title->id; // title is too generic
394 $field_title->value = $screen->getValue($field_title->id);
395 $field_title->is_responsive = false;
396 $field_title->help = __('<p>This text will appear when hovering over the button. You can try this in the preview.</p>
397 <p class="shortcode">Shortcode attribute : linktitle</p>', 'maxbuttons');
398 $screen->addField($field_title, 'start', 'end');
399
400 // TEXT
401 $field_text = new maxField();
402 $field_text->label = __('Text','maxbuttons');
403 $field_text->id = $screen->getFieldID('text');
404 $field_text->name = $field_text->id;
405 $field_text->is_responsive = false;
406 $field_text->value = esc_attr($screen->getValue($field_text->id));
407 $field_text->help = __('Shortcode attribute: text');
408 $screen->addField($field_text, 'start', 'end');
409
410
411 // FONTS
412 $fonts = MB()->getClass('admin')->loadFonts();
413
414 $field_font = new maxField('option_select');
415 $field_font->label = __('Font','maxbuttons');
416
417 $field_font->id = $screen->getFieldID('font');
418 $field_font->name = $field_font->id;
419 $field_font->selected = $screen->getValue($field_font->id);
420 $field_font->options = $fonts;
421
422 $screen->addField($field_font,'start');
423
424 // FONT SIZE
425 //global $maxbuttons_font_sizes;
426 // $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
427
428 $field_size = new maxField('number');
429 $field_size->id= $screen->getFieldID('font_size');
430 $field_size->name = $field_size->id;
431 $field_size->inputclass = 'tiny';
432 $field_size->min = 8;
433 $field_size->after_input = __('px', 'maxbuttons');
434 $field_size->value = maxUtils::strip_px($screen->getValue($field_size->id));
435 $screen->addField($field_size);
436
437 // Font style checkboxes
438 $fweight = new maxField('checkbox');
439 $fweight->icon = 'dashicons-editor-bold';
440 $fweight->title = __("Bold",'maxbuttons');
441 $fweight->id = $screen->getFieldID('check_fweight');
442 $fweight->name = $screen->getFieldID('font_weight');
443 $fweight->value = 'bold';
444 $fweight->inputclass = 'check_button icon';
445 $fweight->checked = checked( $screen->getValue($fweight->name), 'bold', false);
446
447 $screen->addField($fweight, 'group_start');
448
449 $fstyle = new maxField('checkbox');
450 $fstyle->icon = 'dashicons-editor-italic';
451 $fstyle->title = __("Italic",'maxbuttons');
452 $fstyle->id = $screen->getFieldID('check_fstyle');
453 $fstyle->name = $screen->getFieldID('font_style');
454 $fstyle->value = 'italic';
455 $fstyle->inputclass = 'check_button icon';
456 $fstyle->checked = checked( $screen->getValue($fstyle->name), 'italic', false);
457 $screen->addField($fstyle, '', 'group_end');
458
459 $falign_left = new maxField('radio');
460 $falign_left->icon = 'dashicons-editor-alignleft';
461 $falign_left->title = __('Align left','maxbuttons');
462 $falign_left->id = $screen->getFieldID('radio_talign_left');
463 $falign_left->name = $screen->getFieldID('text_align');
464 $falign_left->value = 'left';
465 $falign_left->inputclass = 'check_button icon';
466 $falign_left->checked = checked ( $screen->getValue($falign_left->name), 'left', false);
467 $screen->addField($falign_left, 'group_start');
468
469 $falign_center = new maxField('radio');
470 $falign_center->icon = 'dashicons-editor-aligncenter';
471 $falign_center->title = __('Align center','maxbuttons');
472 $falign_center->id = $screen->getFieldID('radio_talign_center');
473 $falign_center->name = $screen->getFieldID('text_align');
474 $falign_center->value = 'center';
475 $falign_center->inputclass = 'check_button icon';
476 $falign_center->checked = checked( $screen->getValue($falign_center->name), 'center', false);
477 $screen->addField($falign_center);
478
479 $falign_right = new maxField('radio');
480 $falign_right->icon = 'dashicons-editor-alignright';
481 $falign_right->title = __('Align right','maxbuttons');
482 $falign_right->id = $screen->getFieldID('radio_talign_right');
483 $falign_right->name = $screen->getFieldID('text_align');
484 $falign_right->value = 'right';
485 $falign_right->inputclass = 'check_button icon';
486 $falign_right->checked = checked( $screen->getValue($falign_right->name), 'right', false);
487 $screen->addField($falign_right, '', array('group_end','end') );
488
489 // Padding - trouble
490 $ptop = new maxField('number');
491 $ptop->label = __('Padding', 'maxbuttons');
492 $ptop->id = $screen->getFieldID('padding_top');
493 $ptop->name = $ptop->id;
494 $ptop->min = 0;
495 $ptop->inputclass = 'tiny';
496 $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >';
497 $ptop->value = maxUtils::strip_px( $screen->getValue($ptop->id));
498 $screen->addField($ptop,'start');
499
500 $pright = new maxField('number');
501 $pright->id = $screen->getFieldID('padding_right');
502 $pright->name = $pright->id;
503 $pright->min = 0;
504 $pright->inputclass = 'tiny';
505 $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >';
506 $pright->value = maxUtils::strip_px($screen->getValue($pright->id));
507 $screen->addField($pright);
508
509 $pbottom = new maxField('number');
510 $pbottom->id = $screen->getFieldID('padding_bottom');
511 $pbottom->name = $pbottom->id;
512 $pbottom->min = 0;
513 $pbottom->inputclass = 'tiny';
514 $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >';
515 $pbottom->value = maxUtils::strip_px($screen->getValue($pbottom->id));
516 $screen->addField($pbottom);
517
518 $pleft = new maxField('number');
519 $pleft->id = $screen->getFieldID('padding_left');
520 $pleft->name = $pleft->id;
521 $pleft->min = 0;
522 $pleft->inputclass = 'tiny';
523 $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >';
524 $pleft->value = maxUtils::strip_px($screen->getValue($pleft->id));
525 $screen->addField($pleft,'', 'end');
526
527 // Text Color
528
529 $fcolor = new maxField('color');
530 $fcolor->id = $screen->getFieldID('text_color');
531 $fcolor->name = $fcolor->id;
532 $fcolor->value = $screen->getColorValue($fcolor->id);
533 $fcolor->label = __('Text Color','maxbuttons');
534 $fcolor->copycolor = true;
535 $fcolor->bindto = $screen->getFieldID('text_color_hover');
536 $fcolor->copypos = 'right';
537 $fcolor->right_title = $color_copy_move;
538 $fcolor->left_title = $color_copy_self;
539 $screen->addField($fcolor, 'start');
540
541 // Text Color Hover
542 $fcolor_hover = new maxField('color');
543 $fcolor_hover->id = $screen->getFieldID('text_color_hover');
544 $fcolor_hover->name = $fcolor_hover->id;
545 $fcolor_hover->value = $screen->getColorValue($fcolor_hover->id);
546 $fcolor_hover->label = __('Text Color Hover','maxbuttons');
547 $fcolor_hover->copycolor = true;
548 $fcolor_hover->bindto = $fcolor->id;
549 $fcolor_hover->copypos = 'left';
550 $fcolor_hover->right_title = $color_copy_self;
551 $fcolor_hover->left_title = $color_copy_move;
552
553 $screen->addField($fcolor_hover, '','end');
554
555 // Fix label for px or %
556 $after_input = ($screen->getValue($screen->getFieldID('button_size_unit_width')) == 'pixel') ? __('px', 'maxbuttons') : __('%','maxbuttons');
557 $after_input = '<span class="unit">' . $after_input . '</span>';
558
559 // Dimension : width
560
561 $field_width = new maxField('number');
562 $field_width->label = __('Button Width','maxbuttons');
563 $field_width->id = $screen->getFieldID('button_width');
564 $field_width->name = $field_width->id;
565 $field_width->inputclass = 'small';
566 $field_width->min = 0;
567 $field_width->after_input = $after_input;
568 $field_width->value = maxUtils::strip_px($screen->getValue($field_width->id)); // strippx?
569 $screen->addField($field_width, 'start');
570
571 // Fix label for px or %
572 $after_input = ($screen->getValue($screen->getFieldID('button_size_unit_height')) == 'pixel') ? __('px', 'maxbuttons') : __('%','maxbuttons');
573 $after_input = '<span class="unit">' . $after_input . '</span>';
574
575 // Dimension : height
576 $field_height = new maxField('number');
577 $field_height->label = __('Button Height','maxbuttons');
578 $field_height->name = $screen->getFieldID('button_height');
579 $field_height->id = $field_height->name;
580 $field_height->inputclass = 'small';
581 $field_height->min = 0;
582 $field_height->after_input = $after_input;
583 $field_height->help = __('Width and Height are optional. When set to 0, button size will be determined by text size plus padding', 'maxbuttons');
584 $field_height->value= maxUtils::strip_px($screen->getValue($field_height->id)); // strippx?
585 $screen->addField($field_height, '', 'end');
586
587 $size_spacer = new maxField('spacer');
588 $size_spacer->label = __('Width Unit', 'maxbuttons');
589 $size_spacer->name = 'size_unit_spacer';
590
591 $screen->addField($size_spacer, 'start', '');
592
593 // Units for width
594 $wsize_unit_px = new maxField('radio');
595 $wsize_unit_px->label = __('px', 'maxbuttons');
596 $wsize_unit_px->name = $screen->getFieldID('button_size_unit_width');
597 $wsize_unit_px->id = $screen->getFieldID('wbutton_size_unit_px');
598 $wsize_unit_px->value = 'pixel';
599 //$wsize_unit_px->before_input = '<label>width</label>';
600
601 $wsize_unit_px->checked = checked( $screen->getValue($wsize_unit_px->name), 'pixel', false);
602
603 $screen->addField($wsize_unit_px, 'group_start', '');
604
605 $wsize_unit_perc = new maxField('radio');
606 $wsize_unit_perc->label = __('%', 'maxbuttons');
607 $wsize_unit_perc->name = $screen->getFieldID('button_size_unit_width');
608 $wsize_unit_perc->id = $screen->getFieldID('wbutton_size_unit_perc');
609 $wsize_unit_perc->value = 'percent';
610 $wsize_unit_perc->checked = checked( $screen->getValue($wsize_unit_perc->name), 'percent', false);
611
612 $screen->addField($wsize_unit_perc, '', 'group_end');
613
614 $sp = new maxField('spacer');
615 $sp->name = 'unit-spacer ';
616 $sp->label = __("Height Unit", 'maxbuttons');
617
618 $screen->addField($sp);
619
620 // Units for height.
621 $hsize_unit_px = new maxField('radio');
622 $hsize_unit_px->label = __('px', 'maxbuttons');
623 $hsize_unit_px->name = $screen->getFieldID('button_size_unit_height');
624 $hsize_unit_px->id = $screen->getFieldID('hbutton_size_unit_px');
625 $hsize_unit_px->value = 'pixel';
626 $hsize_unit_px->checked = checked( $screen->getValue($hsize_unit_px->name), 'pixel', false);
627 $screen->addField($hsize_unit_px, 'group_start', '');
628
629 $hsize_unit_perc = new maxField('radio');
630 $hsize_unit_perc->label = __('%', 'maxbuttons');
631 $hsize_unit_perc->name = $screen->getFieldID('button_size_unit_height');
632 $hsize_unit_perc->id = $screen->getFieldID('hbutton_size_unit_perc');
633 $hsize_unit_perc->value = 'percent';
634 $hsize_unit_perc->checked = checked( $screen->getValue($hsize_unit_perc->name), 'percent', false);
635 $hsize_unit_perc->help = __('Using percentages makes the button size to the page element. The live preview can be unreliable', 'maxbuttons');
636 $screen->addField($hsize_unit_perc, '', array('group_end', 'end'));
637
638
639 // Description
640 $description_hide = get_option('maxbuttons_hidedescription');
641 if ($description_hide == 1)
642 $field_desc = new maxField('hidden');
643 else
644 $field_desc = new maxField('textarea');
645
646 $field_desc->label = __('Description', 'maxbuttons');
647 $field_desc->id = $screen->getFieldID('description');
648 $field_desc->name = $field_desc->id;
649 $field_desc->esc_function = 'esc_textarea';
650 $field_desc->value = $screen->getValue($field_desc->id);
651 $field_desc->is_responsive = false;
652 $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons');
653
654 $screen->addField($field_desc, 'start', 'end');
655
656 $this->sidebar($screen);
657 $endblock = new maxField('block_end');
658 $screen->addField($endblock);
659
660 } // admin_display
661
662 } // class
663