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 +68 -99 7.13.36.28 View file →
@@ -32,8 +32,9 @@
32 32 $this->protocols = array_merge($this->protocols, $extra_protocols);
33 33 }
34 34 }
35 35
36 +
36 37 public function parse_css($css, $mode = 'normal')
37 38 {
38 39 // emtpy string init is not like by PHP 7.1
39 40 if (! is_array($css))
@@ -44,22 +45,11 @@
44 45 $css["maxbutton"]["normal"]["position"] = "relative";
45 46 $css["maxbutton"]["normal"]["text-decoration"] = "none";
46 47 // $css["maxbutton"]["normal"]["white-space"] = "nowrap"; // hinders correct rendering of oneline-multilines
47 48 $css["maxbutton"]["normal"]["display"] = "inline-block";
48 - $css["maxbutton"]["normal"]["vertical-align"] = 'middle';
49 49
50 - // option to show border boxed buttons in preview area.
51 - $border_box = get_option('maxbuttons_borderbox');
52 -
53 - if ($border_box == 1)
50 + /*if (isset($data["url"]) && $data["url"] == '') // don't show clickable anchor if there is no URL.
54 51 {
55 - $css['maxbutton']['normal']['box-sizing'] = 'border-box';
56 - }
57 -
58 - $css = parent::parse_css($css, $mode);
59 -
60 - /*if (isset($data["url"]) && $data["url"] == '') // don't show clickable anchor if there is no URL.
61 - {
62 52 $css["maxbutton"]["normal"]["cursor"] = 'default';
63 53 // $css[":hover"]["cursor"] = 'default';
64 54 } */
65 55
@@ -73,15 +63,16 @@
73 63 // $post["url"] = isset($post["url"]) ? urldecode(urldecode($post["url"])) : '';
74 64
75 65 $description = false;
76 66
77 - if (isset($post["description"]) && $post["description"] != '')
78 - {
79 - $description = str_replace("\n", '-nwline-', $post["description"]);
67 + if (isset($post["description"]) && $post["description"] != '')
68 + {
69 + $description = str_replace("\n", '-nwline-', $post["description"]);
80 70 $description = sanitize_text_field($description);
81 71 $description = str_replace('-nwline-', "\n", $description);
82 - }
83 72
73 + }
74 +
84 75 $data = parent::save_fields($data, $post);
85 76
86 77 // bypass sanitize for description - causing the end of line-breaks
87 78 if ($description)
@@ -89,16 +80,9 @@
89 80
90 81 // bypassing sanitize text field - causes problems with URLs and spaces
91 82 $url = isset($post["url"]) ? trim($post["url"]) : '';
92 83
93 - // filter zero width space ( https://en.wikipedia.org/wiki/Zero-width_space ) in URL
94 - // https://stackoverflow.com/questions/22600235/remove-unicode-zero-width-space-php
95 - $url = str_replace("​", "", $url);
96 - $url = str_replace("\xE2\x80\x8C", "", $url);
97 - $url = str_replace("\xE2\x80\x8B", "", $url);
98 -
99 84 $parsed_url = parse_url($url);
100 -
101 85 $rawEncode = array("query","fragment");
102 86 foreach($rawEncode as $item)
103 87 {
104 88 if (isset($parsed_url[$item]))
@@ -131,8 +115,9 @@
131 115 $scheme = $parsed_url["scheme"] . ":";
132 116 else
133 117 $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
134 118
119 +
135 120 $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
136 121 $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
137 122 $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
138 123 $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
@@ -200,8 +185,9 @@
200 185 $url = rawurldecode($url); // removes the + from a URL part.
201 186 $url = apply_filters('mb-url', $url, $data['url']); // passes processed url / raw url.
202 187 $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
203 188
189 +
204 190 $anchor->href = $url;
205 191 //do_shortcode( esc_url($url, $this->protocols) );
206 192
207 193 }
@@ -216,9 +202,9 @@
216 202 }
217 203
218 204 public function map_fields($map)
219 205 {
220 - $map = parent::map_fields($map);
206 +
221 207 $map["url"]["attr"] = "href";
222 208 $map["link_title"]["attr"] = "title";
223 209
224 210 // $map["text"]["func"] = "updateAnchorText";
@@ -225,69 +211,32 @@
225 211
226 212 return $map;
227 213 }
228 214
229 - public function check_unique_name($name)
230 - {
231 - global $wpdb;
232 - $table = maxUtils::get_table_name();
233 -
234 - $button_id = $this->data['id'];
235 -
236 - if (strlen($name) == 0 || $name == '')
237 - return false;
238 -
239 - if ($button_id <= 0)
240 - return false;
241 -
242 - $sql = $wpdb->prepare("SELECT id from $table where name = %s and status = 'publish' and id <> %d ", $name, $button_id);
243 -
244 - $results = $wpdb->get_col($sql);
245 -
246 - if (count($results) > 0)
247 - {
248 - $message = __('Button name already used. Using non-unique names with the shortcode can cause issues', 'maxbuttons');
249 - $message .= ' ' . __('Already used in : ');
250 - foreach($results as $id)
251 - {
252 - $url = admin_url() . 'admin.php?page=maxbuttons-controller&action=button&id=' . $id;
253 - $message .= ' <a href="' . $url . '" target="_blank">' . $id . '</a> ';
254 - }
255 -
256 - return $message;
257 - }
258 - }
259 -
260 215 public function admin_fields()
261 216 {
262 217
263 218 $icon_url = MB()->get_plugin_url() . 'images/icons/';
264 219 $admin = MB()->getClass('admin');
220 +?>
265 221
266 -
267 - $start_block = new maxField('block_start');
268 - $start_block->name = __('basic', 'maxbuttons');
269 - $start_block->label = __('Basics', 'maxbuttons');
270 - $admin->addField($start_block);
271 -
222 + <div class="mb_tab option-container mb_tab">
223 + <div class="title"><?php _e('Basics', 'maxbuttons') ?></div>
224 + <div class="inside basic">
225 + <?php
272 226 $color_copy_self = __("Replace color from other field", "maxbuttons");
273 227 $color_copy_move = __("Copy Color to other field", "maxbuttons");
274 228
275 - $check_name = $this->check_unique_name(maxBlocks::getValue('name'));
276 -
277 229 // Name
278 230 $field_name = new maxField() ;
279 231 $field_name->label = __('Button Name', 'maxbuttons');
232 + // $field_name->note = __('Something that you can quickly identify the button with.', 'maxbuttons');
280 233 $field_name->value = maxBlocks::getValue('name');
281 234 $field_name->id = 'name';
282 235 $field_name->name = $field_name->id;
283 236 $field_name->placeholder = __("Button Name","maxbuttons");
237 + // $field_name->output('start','end');
284 238
285 - if ($check_name)
286 - {
287 - $field_name->warning = $check_name;
288 - //$field_name->error = $check_name;
289 - }
290 239 $admin->addField($field_name, 'start', 'end');
291 240
292 241 // URL
293 242 $field_url = new maxField();
@@ -296,32 +245,18 @@
296 245 $field_url->value = rawurldecode(maxBlocks::getValue('url') );
297 246 $field_url->id = 'url';
298 247 $field_url->placeholder = __("http://","maxbuttons");
299 248 $field_url->name = $field_url->id;
300 - $field_url->help = "<p>Enter any URL you wish to link to. </p>
301 - <p>Examples: <br><ul class='nowrap'><li> https://example.com/ </li>
302 - <li> /local-page/ </li>
303 - <li> javascript:window.history.back(); </li></ul></p>
304 - <p class='shortcode'> Shortcode attribute : url </p> ";
305 - $admin->addField($field_url,'start');
306 249
307 - $url_button = new maxField('button');
308 - $url_button->id = 'url_button';
309 - $url_button->name = $url_button->id;
310 - $url_button->button_label = __('Select Site Content', 'maxbuttons');
311 - $admin->addField($url_button, '', 'end');
250 + //$field_url->output('start','end');
251 + $admin->addField($field_url,'start', 'end');
312 252
313 - $url_nonce = new maxField('hidden');
314 - $url_nonce->id = '_ajax_linking_nonce';
315 - $url_nonce->name = $url_nonce->id;
316 - $url_nonce->value = wp_create_nonce('internal-linking');
317 -
318 - $admin->addField($url_nonce);
319 -
320 253 // Spacer
321 254 $fspacer = new maxField('spacer');
322 255 $fspacer->name = 'url_options';
323 256 $fspacer->label = '&nbsp;';
257 + // $fspacer->output('start');
258 +
324 259 $admin->addField($fspacer, 'start');
325 260
326 261 // New Window
327 262 $fwindow = new maxField('checkbox');
@@ -328,9 +263,12 @@
328 263 $fwindow->label = __('Open in New Window', 'maxbuttons');
329 264 $fwindow->name = 'new_window';
330 265 $fwindow->id = $fwindow->name;
331 266 $fwindow->value = 1;
267 + //$fwindow->inputclass = 'check_button';
332 268 $fwindow->checked = checked( maxBlocks::getValue('new_window'), 1, false);
269 +
270 + //$fwindow->output('','');
333 271 $admin->addField($fwindow);
334 272
335 273 // NoRel
336 274 $ffollow = new maxField('checkbox');
@@ -338,8 +276,10 @@
338 276 $ffollow->value = 1;
339 277 $ffollow->name = 'nofollow';
340 278 $ffollow->id = $ffollow->name;
341 279 $ffollow->checked = checked( maxBlocks::getValue('nofollow'), 1, false);
280 +
281 + //$ffollow->output('','end');
342 282 $admin->addField($ffollow, '','end');
343 283 // TITLE
344 284
345 285 $field_title = new maxField();
@@ -346,10 +286,10 @@
346 286 $field_title->label = __('Button Tooltip', 'maxbuttons');
347 287 $field_title->name = 'link_title'; // title is too generic
348 288 $field_title->id = $field_title->name;
349 289 $field_title->value = maxBlocks::getValue('link_title');
350 - $field_title->help = __('<p>This text will appear when hovering over the button</p>
351 - <p class="shortcode">Shortcode attribute : linktitle</p>', 'maxbuttons');
290 +
291 + //$field_title->output('start','end');
352 292 $admin->addField($field_title, 'start', 'end');
353 293
354 294 // TEXT
355 295 $field_text = new maxField();
@@ -356,20 +296,23 @@
356 296 $field_text->label = __('Text','maxbuttons');
357 297 $field_text->name = 'text';
358 298 $field_text->id = 'text';
359 299 $field_text->value = maxBlocks::getValue('text') ;
300 +
301 + // $field_text->output('start','end');
360 302 $admin->addField($field_text, 'start', 'end');
361 303
362 304 // FONTS
363 305 $fonts = MB()->getClass('admin')->loadFonts();
364 306
365 - $field_font = new maxField('option_select');
307 + $field_font = new maxField('generic');
366 308 $field_font->label = __('Font','maxbuttons');
367 309 $field_font->name = 'font';
368 310 $field_font->id = $field_font->name;
369 - $field_font->selected = maxBlocks::getValue('font');
370 - $field_font->options = $fonts;
311 + $field_font->value= maxBlocks::getValue('font');
312 + $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
371 313
314 + //$field_font->output('start');
372 315 $admin->addField($field_font,'start');
373 316 ?>
374 317
375 318 <?php
@@ -378,14 +321,17 @@
378 321 $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
379 322
380 323
381 324 $field_size = new maxField('number');
325 + // $field_size->label = '';
382 326 $field_size->name = 'font_size';
383 327 $field_size->id= $field_size->name;
384 328 $field_size->inputclass = 'tiny';
385 329 $field_size->min = 8;
386 - $field_size->after_input = __('px', 'maxbuttons');
387 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');
332 +
333 + //$field_size->output();
388 334 $admin->addField($field_size);
389 335
390 336 // Font style checkboxes
391 337 $fweight = new maxField('checkbox');
@@ -395,8 +341,10 @@
395 341 $fweight->name = 'font_weight';
396 342 $fweight->value = 'bold';
397 343 $fweight->inputclass = 'check_button icon';
398 344 $fweight->checked = checked( maxBlocks::getValue('font_weight'), 'bold', false);
345 +
346 + // $fweight->output('group_start');
399 347 $admin->addField($fweight, 'group_start');
400 348
401 349 $fstyle = new maxField('checkbox');
402 350 $fstyle->icon = 'dashicons-editor-italic';
@@ -405,8 +353,10 @@
405 353 $fstyle->name = 'font_style';
406 354 $fstyle->value = 'italic';
407 355 $fstyle->inputclass = 'check_button icon';
408 356 $fstyle->checked = checked( maxBlocks::getValue('font_style'), 'italic', false);
357 +
358 + //$fstyle->output('','group_end');
409 359 $admin->addField($fstyle, '', 'group_end');
410 360
411 361 $falign_left = new maxField('radio');
412 362 $falign_left->icon = 'dashicons-editor-alignleft';
@@ -415,8 +365,10 @@
415 365 $falign_left->name = 'text_align';
416 366 $falign_left->value = 'left';
417 367 $falign_left->inputclass = 'check_button icon';
418 368 $falign_left->checked = checked ( maxblocks::getValue('text_align'), 'left', false);
369 +
370 + //$falign_left->output('group_start');
419 371 $admin->addField($falign_left, 'group_start');
420 372
421 373 $falign_center = new maxField('radio');
422 374 $falign_center->icon = 'dashicons-editor-aligncenter';
@@ -425,8 +377,10 @@
425 377 $falign_center->name = 'text_align';
426 378 $falign_center->value = 'center';
427 379 $falign_center->inputclass = 'check_button icon';
428 380 $falign_center->checked = checked( maxblocks::getValue('text_align'), 'center', false);
381 +
382 + //$falign_center->output();
429 383 $admin->addField($falign_center);
430 384
431 385 $falign_right = new maxField('radio');
432 386 $falign_right->icon = 'dashicons-editor-alignright';
@@ -435,8 +389,10 @@
435 389 $falign_right->name = 'text_align';
436 390 $falign_right->value = 'right';
437 391 $falign_right->inputclass = 'check_button icon';
438 392 $falign_right->checked = checked( maxblocks::getValue('text_align'), 'right', false);
393 +
394 + //$falign_right->output('', array('group_end','end') );
439 395 $admin->addField($falign_right, '', array('group_end','end') );
440 396
441 397 // Padding - trouble
442 398 $ptop = new maxField('number');
@@ -446,8 +402,10 @@
446 402 $ptop->min = 0;
447 403 $ptop->inputclass = 'tiny';
448 404 $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >';
449 405 $ptop->value = maxUtils::strip_px(maxBlocks::getValue('padding_top'));
406 +
407 + //$ptop->output('start');
450 408 $admin->addField($ptop,'start');
451 409
452 410 $pright = new maxField('number');
453 411 $pright->id = 'padding_right';
@@ -455,8 +413,10 @@
455 413 $pright->min = 0;
456 414 $pright->inputclass = 'tiny';
457 415 $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >';
458 416 $pright->value = maxUtils::strip_px(maxBlocks::getValue('padding_right'));
417 +
418 + //$pright->output();
459 419 $admin->addField($pright);
460 420
461 421 $pbottom = new maxField('number');
462 422 $pbottom->id = 'padding_bottom';
@@ -464,8 +424,10 @@
464 424 $pbottom->min = 0;
465 425 $pbottom->inputclass = 'tiny';
466 426 $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >';
467 427 $pbottom->value = maxUtils::strip_px(maxBlocks::getValue('padding_bottom'));
428 +
429 + //$pbottom->output();
468 430 $admin->addField($pbottom);
469 431
470 432 $pleft = new maxField('number');
471 433 $pleft->id = 'padding_left';
@@ -473,8 +435,10 @@
473 435 $pleft->min = 0;
474 436 $pleft->inputclass = 'tiny';
475 437 $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >';
476 438 $pleft->value = maxUtils::strip_px(maxBlocks::getValue('padding_left'));
439 +
440 + //$pleft->output('','end');
477 441 $admin->addField($pleft,'', 'end');
478 442
479 443
480 444 // Text Color
@@ -487,8 +451,10 @@
487 451 $fcolor->bindto = 'text_color_hover';
488 452 $fcolor->copypos = 'right';
489 453 $fcolor->right_title = $color_copy_move;
490 454 $fcolor->left_title = $color_copy_self;
455 +
456 + // $fcolor->output('start');
491 457 $admin->addField($fcolor, 'start');
492 458
493 459 // Text Color Hover
494 460 $fcolor_hover = new maxField('color');
@@ -500,8 +466,9 @@
500 466 $fcolor_hover->bindto = $fcolor->id;
501 467 $fcolor_hover->copypos = 'left';
502 468 $fcolor_hover->right_title = $color_copy_self;
503 469 $fcolor_hover->left_title = $color_copy_move;
470 + //$fcolor_hover->output('','end');
504 471
505 472 $admin->addField($fcolor_hover, '','end');
506 473
507 474 // Dimension : width
@@ -510,10 +477,10 @@
510 477 $field_width->name = 'button_width';
511 478 $field_width->id = $field_width->name;
512 479 $field_width->inputclass = 'small';
513 480 $field_width->min = 0;
514 - $field_width->after_input = __('px', 'maxbuttons');
515 481 $field_width->value= maxUtils::strip_px(maxBlocks::getValue('button_width')); // strippx?
482 + //$field_width->output('start');
516 483
517 484 $admin->addField($field_width, 'start');
518 485
519 486 // Dimension : height
@@ -522,11 +489,10 @@
522 489 $field_height->name = 'button_height';
523 490 $field_height->id = $field_height->name;
524 491 $field_height->inputclass = 'small';
525 492 $field_height->min = 0;
526 - $field_height->after_input = __('px', 'maxbuttons');
527 - $field_height->help = __('Width and Height are optional. When set to 0,button size will be determined by text size plus padding', 'maxbuttons');
528 493 $field_height->value= maxUtils::strip_px(maxBlocks::getValue('button_height')); // strippx?
494 + //$field_height->output('','end');
529 495
530 496 $admin->addField($field_height, '', 'end');
531 497
532 498 // Description
@@ -541,16 +507,19 @@
541 507 $field_desc->id = $field_desc->name;
542 508 $field_desc->esc_function = 'esc_textarea';
543 509 $field_desc->value = maxBlocks::getValue('description') ;
544 510 $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons');
511 + //$field_desc->output('start','end');
545 512
546 513 $admin->addField($field_desc, 'start', 'end');
547 514
548 - $this->sidebar();
549 - $endblock = new maxField('block_end');
550 - $admin->addField($endblock);
515 + $admin->display_fields();
516 + ?>
551 517
552 - } // admin_display
518 +
519 + </div>
520 + </div>
521 +<?php } // admin_display
553 522
554 523 } // class
555 524
556 525 ?>