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 +82 -47 6.246.28 View file →
@@ -17,14 +17,21 @@
17 17 // "text" => array("default" => ''),
18 18 "new_window" => array("default" => 0),
19 19 "nofollow" => array("default" => 0)
20 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'); // allowed url protocols for esc_url functions
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
22 22
23 23
24 24 function __construct()
25 25 {
26 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 35
29 36
30 37 public function parse_css($css, $mode = 'normal')
@@ -49,10 +56,8 @@
49 56 return $css;
50 57
51 58 }
52 59
53 -
54 -
55 60 public function save_fields($data, $post)
56 61 {
57 62 // Possible solution:
58 63 // $post["url"] = isset($post["url"]) ? urldecode(urldecode($post["url"])) : '';
@@ -132,11 +137,9 @@
132 137 {
133 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 {
@@ -142,20 +145,36 @@
142 145 {
143 146
144 147 $data = $this->data[$this->blockname];
145 148 $button_id = $this->data["id"];
149 + $rels = array();
146 150
147 151 $anchor = $domObj->find("a",0);
148 152
149 153 if (isset($data["nofollow"]) && $data["nofollow"] == 1)
150 - $anchor->rel = "nofollow";
154 + {
155 + $rels[] = 'nofollow';
156 + $rels[] = 'noopener';
157 + }
158 + // $anchor->rel = "nofollow";
151 159 // $buttonAttrs[] = "rel=nofollow";
160 +
152 161 if (isset($data["new_window"]) && $data["new_window"] == 1)
162 + {
153 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 168 $anchor->title = $data['link_title'];
156 169
170 + $rels = apply_filters('mb/button/rel', $rels);
157 171
172 + if (count($rels) > 0)
173 + {
174 + $anchor->rel = implode(' ', $rels);
175 + }
176 +
158 177 if (isset($data["url"]) && $data["url"] != '')
159 178 {
160 179 $url = $data["url"];
161 180 $parsed_url = parse_url($url);
@@ -194,19 +213,11 @@
194 213 }
195 214
196 215 public function admin_fields()
197 216 {
198 - //parent::admin_fields();
199 217
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/' ;
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>
@@ -222,10 +233,11 @@
222 233 $field_name->value = maxBlocks::getValue('name');
223 234 $field_name->id = 'name';
224 235 $field_name->name = $field_name->id;
225 236 $field_name->placeholder = __("Button Name","maxbuttons");
226 - $field_name->output('start','end');
237 + // $field_name->output('start','end');
227 238
239 + $admin->addField($field_name, 'start', 'end');
228 240
229 241 // URL
230 242 $field_url = new maxField();
231 243 $field_url->label = __('URL', 'maxbuttons');
@@ -234,16 +246,18 @@
234 246 $field_url->id = 'url';
235 247 $field_url->placeholder = __("http://","maxbuttons");
236 248 $field_url->name = $field_url->id;
237 249
238 - $field_url->output('start','end');
250 + //$field_url->output('start','end');
251 + $admin->addField($field_url,'start', 'end');
239 252
240 253 // Spacer
241 254 $fspacer = new maxField('spacer');
242 255 $fspacer->name = 'url_options';
243 256 $fspacer->label = '&nbsp;';
244 - $fspacer->output('start');
257 + // $fspacer->output('start');
245 258
259 + $admin->addField($fspacer, 'start');
246 260
247 261 // New Window
248 262 $fwindow = new maxField('checkbox');
249 263 $fwindow->label = __('Open in New Window', 'maxbuttons');
@@ -252,13 +266,11 @@
252 266 $fwindow->value = 1;
253 267 //$fwindow->inputclass = 'check_button';
254 268 $fwindow->checked = checked( maxBlocks::getValue('new_window'), 1, false);
255 269
256 - $fwindow->output('','');
270 + //$fwindow->output('','');
271 + $admin->addField($fwindow);
257 272
258 - //$fspacer->name ='rel_options';
259 - //$fspacer->output('start');
260 -
261 273 // NoRel
262 274 $ffollow = new maxField('checkbox');
263 275 $ffollow->label = __('Use rel="nofollow"', 'maxbuttons');
264 276 $ffollow->value = 1;
@@ -265,19 +277,20 @@
265 277 $ffollow->name = 'nofollow';
266 278 $ffollow->id = $ffollow->name;
267 279 $ffollow->checked = checked( maxBlocks::getValue('nofollow'), 1, false);
268 280
269 - $ffollow->output('','end');
270 -
281 + //$ffollow->output('','end');
282 + $admin->addField($ffollow, '','end');
271 283 // TITLE
272 284
273 285 $field_title = new maxField();
274 - $field_title->label = __('Button Title', 'maxbuttons');
286 + $field_title->label = __('Button Tooltip', 'maxbuttons');
275 287 $field_title->name = 'link_title'; // title is too generic
276 288 $field_title->id = $field_title->name;
277 289 $field_title->value = maxBlocks::getValue('link_title');
278 290
279 - $field_title->output('start','end');
291 + //$field_title->output('start','end');
292 + $admin->addField($field_title, 'start', 'end');
280 293
281 294 // TEXT
282 295 $field_text = new maxField();
283 296 $field_text->label = __('Text','maxbuttons');
@@ -284,9 +297,10 @@
284 297 $field_text->name = 'text';
285 298 $field_text->id = 'text';
286 299 $field_text->value = maxBlocks::getValue('text') ;
287 300
288 - $field_text->output('start','end');
301 + // $field_text->output('start','end');
302 + $admin->addField($field_text, 'start', 'end');
289 303
290 304 // FONTS
291 305 $fonts = MB()->getClass('admin')->loadFonts();
292 306
@@ -296,9 +310,10 @@
296 310 $field_font->id = $field_font->name;
297 311 $field_font->value= maxBlocks::getValue('font');
298 312 $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
299 313
300 - $field_font->output('start');
314 + //$field_font->output('start');
315 + $admin->addField($field_font,'start');
301 316 ?>
302 317
303 318 <?php
304 319 // FONT SIZE
@@ -314,9 +329,10 @@
314 329 $field_size->min = 8;
315 330 $field_size->value = maxUtils::strip_px(maxBlocks::getValue('font_size'));
316 331 //$field_size->content = maxUtils::selectify($field_size->name, $sizes, $field_size->value, '', 'small');
317 332
318 - $field_size->output();
333 + //$field_size->output();
334 + $admin->addField($field_size);
319 335
320 336 // Font style checkboxes
321 337 $fweight = new maxField('checkbox');
322 338 $fweight->icon = 'dashicons-editor-bold';
@@ -326,9 +342,10 @@
326 342 $fweight->value = 'bold';
327 343 $fweight->inputclass = 'check_button icon';
328 344 $fweight->checked = checked( maxBlocks::getValue('font_weight'), 'bold', false);
329 345
330 - $fweight->output('group_start');
346 + // $fweight->output('group_start');
347 + $admin->addField($fweight, 'group_start');
331 348
332 349 $fstyle = new maxField('checkbox');
333 350 $fstyle->icon = 'dashicons-editor-italic';
334 351 $fstyle->title = __("Italic",'maxbuttons');
@@ -337,11 +354,11 @@
337 354 $fstyle->value = 'italic';
338 355 $fstyle->inputclass = 'check_button icon';
339 356 $fstyle->checked = checked( maxBlocks::getValue('font_style'), 'italic', false);
340 357
341 - $fstyle->output('','group_end');
358 + //$fstyle->output('','group_end');
359 + $admin->addField($fstyle, '', 'group_end');
342 360
343 -
344 361 $falign_left = new maxField('radio');
345 362 $falign_left->icon = 'dashicons-editor-alignleft';
346 363 $falign_left->title = __('Align left','maxbuttons');
347 364 $falign_left->id = 'radio_talign_left';
@@ -349,9 +366,10 @@
349 366 $falign_left->value = 'left';
350 367 $falign_left->inputclass = 'check_button icon';
351 368 $falign_left->checked = checked ( maxblocks::getValue('text_align'), 'left', false);
352 369
353 - $falign_left->output('group_start');
370 + //$falign_left->output('group_start');
371 + $admin->addField($falign_left, 'group_start');
354 372
355 373 $falign_center = new maxField('radio');
356 374 $falign_center->icon = 'dashicons-editor-aligncenter';
357 375 $falign_center->title = __('Align center','maxbuttons');
@@ -360,9 +378,10 @@
360 378 $falign_center->value = 'center';
361 379 $falign_center->inputclass = 'check_button icon';
362 380 $falign_center->checked = checked( maxblocks::getValue('text_align'), 'center', false);
363 381
364 - $falign_center->output();
382 + //$falign_center->output();
383 + $admin->addField($falign_center);
365 384
366 385 $falign_right = new maxField('radio');
367 386 $falign_right->icon = 'dashicons-editor-alignright';
368 387 $falign_right->title = __('Align right','maxbuttons');
@@ -371,9 +390,10 @@
371 390 $falign_right->value = 'right';
372 391 $falign_right->inputclass = 'check_button icon';
373 392 $falign_right->checked = checked( maxblocks::getValue('text_align'), 'right', false);
374 393
375 - $falign_right->output('', array('group_end','end') );
394 + //$falign_right->output('', array('group_end','end') );
395 + $admin->addField($falign_right, '', array('group_end','end') );
376 396
377 397 // Padding - trouble
378 398 $ptop = new maxField('number');
379 399 $ptop->label = __('Padding', 'maxbuttons');
@@ -383,9 +403,10 @@
383 403 $ptop->inputclass = 'tiny';
384 404 $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >';
385 405 $ptop->value = maxUtils::strip_px(maxBlocks::getValue('padding_top'));
386 406
387 - $ptop->output('start');
407 + //$ptop->output('start');
408 + $admin->addField($ptop,'start');
388 409
389 410 $pright = new maxField('number');
390 411 $pright->id = 'padding_right';
391 412 $pright->name = $pright->id;
@@ -393,9 +414,10 @@
393 414 $pright->inputclass = 'tiny';
394 415 $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >';
395 416 $pright->value = maxUtils::strip_px(maxBlocks::getValue('padding_right'));
396 417
397 - $pright->output();
418 + //$pright->output();
419 + $admin->addField($pright);
398 420
399 421 $pbottom = new maxField('number');
400 422 $pbottom->id = 'padding_bottom';
401 423 $pbottom->name = $pbottom->id;
@@ -403,9 +425,10 @@
403 425 $pbottom->inputclass = 'tiny';
404 426 $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >';
405 427 $pbottom->value = maxUtils::strip_px(maxBlocks::getValue('padding_bottom'));
406 428
407 - $pbottom->output();
429 + //$pbottom->output();
430 + $admin->addField($pbottom);
408 431
409 432 $pleft = new maxField('number');
410 433 $pleft->id = 'padding_left';
411 434 $pleft->name = $pleft->id;
@@ -413,9 +436,10 @@
413 436 $pleft->inputclass = 'tiny';
414 437 $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >';
415 438 $pleft->value = maxUtils::strip_px(maxBlocks::getValue('padding_left'));
416 439
417 - $pleft->output('','end');
440 + //$pleft->output('','end');
441 + $admin->addField($pleft,'', 'end');
418 442
419 443
420 444 // Text Color
421 445 $fcolor = new maxField('color');
@@ -427,10 +451,12 @@
427 451 $fcolor->bindto = 'text_color_hover';
428 452 $fcolor->copypos = 'right';
429 453 $fcolor->right_title = $color_copy_move;
430 454 $fcolor->left_title = $color_copy_self;
431 - $fcolor->output('start');
432 455
456 + // $fcolor->output('start');
457 + $admin->addField($fcolor, 'start');
458 +
433 459 // Text Color Hover
434 460 $fcolor_hover = new maxField('color');
435 461 $fcolor_hover->id = 'text_color_hover';
436 462 $fcolor_hover->name = $fcolor_hover->id;
@@ -439,11 +465,13 @@
439 465 $fcolor_hover->copycolor = true;
440 466 $fcolor_hover->bindto = $fcolor->id;
441 467 $fcolor_hover->copypos = 'left';
442 468 $fcolor_hover->right_title = $color_copy_self;
443 - $fcolor_hover->left_title = $color_copy_move;
444 - $fcolor_hover->output('','end');
469 + $fcolor_hover->left_title = $color_copy_move;
470 + //$fcolor_hover->output('','end');
445 471
472 + $admin->addField($fcolor_hover, '','end');
473 +
446 474 // Dimension : width
447 475 $field_width = new maxField('number');
448 476 $field_width->label = __('Button Width','maxbuttons');
449 477 $field_width->name = 'button_width';
@@ -450,10 +478,12 @@
450 478 $field_width->id = $field_width->name;
451 479 $field_width->inputclass = 'small';
452 480 $field_width->min = 0;
453 481 $field_width->value= maxUtils::strip_px(maxBlocks::getValue('button_width')); // strippx?
454 - $field_width->output('start');
482 + //$field_width->output('start');
455 483
484 + $admin->addField($field_width, 'start');
485 +
456 486 // Dimension : height
457 487 $field_height = new maxField('number');
458 488 $field_height->label = __('Button Height','maxbuttons');
459 489 $field_height->name = 'button_height';
@@ -460,10 +490,12 @@
460 490 $field_height->id = $field_height->name;
461 491 $field_height->inputclass = 'small';
462 492 $field_height->min = 0;
463 493 $field_height->value= maxUtils::strip_px(maxBlocks::getValue('button_height')); // strippx?
464 - $field_height->output('','end');
494 + //$field_height->output('','end');
465 495
496 + $admin->addField($field_height, '', 'end');
497 +
466 498 // Description
467 499 $description_hide = get_option('maxbuttons_hidedescription');
468 500 if ($description_hide == 1)
469 501 $field_desc = new maxField('hidden');
@@ -475,11 +507,14 @@
475 507 $field_desc->id = $field_desc->name;
476 508 $field_desc->esc_function = 'esc_textarea';
477 509 $field_desc->value = maxBlocks::getValue('description') ;
478 510 $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons');
479 - $field_desc->output('start','end');
511 + //$field_desc->output('start','end');
480 512
481 - ?>
513 + $admin->addField($field_desc, 'start', 'end');
514 +
515 + $admin->display_fields();
516 + ?>
482 517
483 518
484 519 </div>
485 520 </div>