| @@ -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 | |
| @@ -212,9 +202,9 @@ | ||
| 212 | 202 | } |
| 213 | 203 | |
| 214 | 204 | public function map_fields($map) |
| 215 | 205 | { |
| 216 | - $map = parent::map_fields($map); | |
| 206 | + | |
| 217 | 207 | $map["url"]["attr"] = "href"; |
| 218 | 208 | $map["link_title"]["attr"] = "title"; |
| 219 | 209 | |
| 220 | 210 | // $map["text"]["func"] = "updateAnchorText"; |
| @@ -221,69 +211,32 @@ | ||
| 221 | 211 | |
| 222 | 212 | return $map; |
| 223 | 213 | } |
| 224 | 214 | |
| 225 | - public function check_unique_name($name) | |
| 226 | - { | |
| 227 | - global $wpdb; | |
| 228 | - $table = maxUtils::get_table_name(); | |
| 229 | - | |
| 230 | - $button_id = $this->data['id']; | |
| 231 | - | |
| 232 | - if (strlen($name) == 0 || $name == '') | |
| 233 | - return false; | |
| 234 | - | |
| 235 | - if ($button_id <= 0) | |
| 236 | - return false; | |
| 237 | - | |
| 238 | - $sql = $wpdb->prepare("SELECT id from $table where name = %s and status = 'publish' and id <> %d ", $name, $button_id); | |
| 239 | - | |
| 240 | - $results = $wpdb->get_col($sql); | |
| 241 | - | |
| 242 | - if (count($results) > 0) | |
| 243 | - { | |
| 244 | - $message = __('Button name already used. Using non-unique names with the shortcode can cause issues', 'maxbuttons'); | |
| 245 | - $message .= ' ' . __('Already used in : '); | |
| 246 | - foreach($results as $id) | |
| 247 | - { | |
| 248 | - $url = admin_url() . 'admin.php?page=maxbuttons-controller&action=button&id=' . $id; | |
| 249 | - $message .= ' <a href="' . $url . '" target="_blank">' . $id . '</a> '; | |
| 250 | - } | |
| 251 | - | |
| 252 | - return $message; | |
| 253 | - } | |
| 254 | - } | |
| 255 | - | |
| 256 | 215 | public function admin_fields() |
| 257 | 216 | { |
| 258 | 217 | |
| 259 | 218 | $icon_url = MB()->get_plugin_url() . 'images/icons/'; |
| 260 | 219 | $admin = MB()->getClass('admin'); |
| 220 | +?> | |
| 261 | 221 | |
| 262 | - | |
| 263 | - $start_block = new maxField('block_start'); | |
| 264 | - $start_block->name = __('basic', 'maxbuttons'); | |
| 265 | - $start_block->label = __('Basics', 'maxbuttons'); | |
| 266 | - $admin->addField($start_block); | |
| 267 | - | |
| 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 | |
| 268 | 226 | $color_copy_self = __("Replace color from other field", "maxbuttons"); |
| 269 | 227 | $color_copy_move = __("Copy Color to other field", "maxbuttons"); |
| 270 | 228 | |
| 271 | - $check_name = $this->check_unique_name(maxBlocks::getValue('name')); | |
| 272 | - | |
| 273 | 229 | // Name |
| 274 | 230 | $field_name = new maxField() ; |
| 275 | 231 | $field_name->label = __('Button Name', 'maxbuttons'); |
| 232 | + // $field_name->note = __('Something that you can quickly identify the button with.', 'maxbuttons'); | |
| 276 | 233 | $field_name->value = maxBlocks::getValue('name'); |
| 277 | 234 | $field_name->id = 'name'; |
| 278 | 235 | $field_name->name = $field_name->id; |
| 279 | 236 | $field_name->placeholder = __("Button Name","maxbuttons"); |
| 237 | + // $field_name->output('start','end'); | |
| 280 | 238 | |
| 281 | - if ($check_name) | |
| 282 | - { | |
| 283 | - $field_name->warning = $check_name; | |
| 284 | - //$field_name->error = $check_name; | |
| 285 | - } | |
| 286 | 239 | $admin->addField($field_name, 'start', 'end'); |
| 287 | 240 | |
| 288 | 241 | // URL |
| 289 | 242 | $field_url = new maxField(); |
| @@ -292,32 +245,18 @@ | ||
| 292 | 245 | $field_url->value = rawurldecode(maxBlocks::getValue('url') ); |
| 293 | 246 | $field_url->id = 'url'; |
| 294 | 247 | $field_url->placeholder = __("http://","maxbuttons"); |
| 295 | 248 | $field_url->name = $field_url->id; |
| 296 | - $field_url->help = "<p>Enter any URL you wish to link to. </p> | |
| 297 | - <p>Examples: <br><ul class='nowrap'><li> https://example.com/ </li> | |
| 298 | - <li> /local-page/ </li> | |
| 299 | - <li> javascript:window.history.back(); </li></ul></p> | |
| 300 | - <p class='shortcode'> Shortcode attribute : url </p> "; | |
| 301 | - $admin->addField($field_url,'start'); | |
| 302 | 249 | |
| 303 | - $url_button = new maxField('button'); | |
| 304 | - $url_button->id = 'url_button'; | |
| 305 | - $url_button->name = $url_button->id; | |
| 306 | - $url_button->button_label = __('Select Site Content', 'maxbuttons'); | |
| 307 | - $admin->addField($url_button, '', 'end'); | |
| 250 | + //$field_url->output('start','end'); | |
| 251 | + $admin->addField($field_url,'start', 'end'); | |
| 308 | 252 | |
| 309 | - $url_nonce = new maxField('hidden'); | |
| 310 | - $url_nonce->id = '_ajax_linking_nonce'; | |
| 311 | - $url_nonce->name = $url_nonce->id; | |
| 312 | - $url_nonce->value = wp_create_nonce('internal-linking'); | |
| 313 | - | |
| 314 | - $admin->addField($url_nonce); | |
| 315 | - | |
| 316 | 253 | // Spacer |
| 317 | 254 | $fspacer = new maxField('spacer'); |
| 318 | 255 | $fspacer->name = 'url_options'; |
| 319 | 256 | $fspacer->label = ' '; |
| 257 | + // $fspacer->output('start'); | |
| 258 | + | |
| 320 | 259 | $admin->addField($fspacer, 'start'); |
| 321 | 260 | |
| 322 | 261 | // New Window |
| 323 | 262 | $fwindow = new maxField('checkbox'); |
| @@ -324,9 +263,12 @@ | ||
| 324 | 263 | $fwindow->label = __('Open in New Window', 'maxbuttons'); |
| 325 | 264 | $fwindow->name = 'new_window'; |
| 326 | 265 | $fwindow->id = $fwindow->name; |
| 327 | 266 | $fwindow->value = 1; |
| 267 | + //$fwindow->inputclass = 'check_button'; | |
| 328 | 268 | $fwindow->checked = checked( maxBlocks::getValue('new_window'), 1, false); |
| 269 | + | |
| 270 | + //$fwindow->output('',''); | |
| 329 | 271 | $admin->addField($fwindow); |
| 330 | 272 | |
| 331 | 273 | // NoRel |
| 332 | 274 | $ffollow = new maxField('checkbox'); |
| @@ -334,8 +276,10 @@ | ||
| 334 | 276 | $ffollow->value = 1; |
| 335 | 277 | $ffollow->name = 'nofollow'; |
| 336 | 278 | $ffollow->id = $ffollow->name; |
| 337 | 279 | $ffollow->checked = checked( maxBlocks::getValue('nofollow'), 1, false); |
| 280 | + | |
| 281 | + //$ffollow->output('','end'); | |
| 338 | 282 | $admin->addField($ffollow, '','end'); |
| 339 | 283 | // TITLE |
| 340 | 284 | |
| 341 | 285 | $field_title = new maxField(); |
| @@ -342,10 +286,10 @@ | ||
| 342 | 286 | $field_title->label = __('Button Tooltip', 'maxbuttons'); |
| 343 | 287 | $field_title->name = 'link_title'; // title is too generic |
| 344 | 288 | $field_title->id = $field_title->name; |
| 345 | 289 | $field_title->value = maxBlocks::getValue('link_title'); |
| 346 | - $field_title->help = __('<p>This text will appear when hovering over the button</p> | |
| 347 | - <p class="shortcode">Shortcode attribute : linktitle</p>', 'maxbuttons'); | |
| 290 | + | |
| 291 | + //$field_title->output('start','end'); | |
| 348 | 292 | $admin->addField($field_title, 'start', 'end'); |
| 349 | 293 | |
| 350 | 294 | // TEXT |
| 351 | 295 | $field_text = new maxField(); |
| @@ -352,20 +296,23 @@ | ||
| 352 | 296 | $field_text->label = __('Text','maxbuttons'); |
| 353 | 297 | $field_text->name = 'text'; |
| 354 | 298 | $field_text->id = 'text'; |
| 355 | 299 | $field_text->value = maxBlocks::getValue('text') ; |
| 300 | + | |
| 301 | + // $field_text->output('start','end'); | |
| 356 | 302 | $admin->addField($field_text, 'start', 'end'); |
| 357 | 303 | |
| 358 | 304 | // FONTS |
| 359 | 305 | $fonts = MB()->getClass('admin')->loadFonts(); |
| 360 | 306 | |
| 361 | - $field_font = new maxField('option_select'); | |
| 307 | + $field_font = new maxField('generic'); | |
| 362 | 308 | $field_font->label = __('Font','maxbuttons'); |
| 363 | 309 | $field_font->name = 'font'; |
| 364 | 310 | $field_font->id = $field_font->name; |
| 365 | - $field_font->selected = maxBlocks::getValue('font'); | |
| 366 | - $field_font->options = $fonts; | |
| 311 | + $field_font->value= maxBlocks::getValue('font'); | |
| 312 | + $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value); | |
| 367 | 313 | |
| 314 | + //$field_font->output('start'); | |
| 368 | 315 | $admin->addField($field_font,'start'); |
| 369 | 316 | ?> |
| 370 | 317 | |
| 371 | 318 | <?php |
| @@ -374,14 +321,17 @@ | ||
| 374 | 321 | $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) ); |
| 375 | 322 | |
| 376 | 323 | |
| 377 | 324 | $field_size = new maxField('number'); |
| 325 | + // $field_size->label = ''; | |
| 378 | 326 | $field_size->name = 'font_size'; |
| 379 | 327 | $field_size->id= $field_size->name; |
| 380 | 328 | $field_size->inputclass = 'tiny'; |
| 381 | 329 | $field_size->min = 8; |
| 382 | - $field_size->after_input = __('px', 'maxbuttons'); | |
| 383 | 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(); | |
| 384 | 334 | $admin->addField($field_size); |
| 385 | 335 | |
| 386 | 336 | // Font style checkboxes |
| 387 | 337 | $fweight = new maxField('checkbox'); |
| @@ -391,8 +341,10 @@ | ||
| 391 | 341 | $fweight->name = 'font_weight'; |
| 392 | 342 | $fweight->value = 'bold'; |
| 393 | 343 | $fweight->inputclass = 'check_button icon'; |
| 394 | 344 | $fweight->checked = checked( maxBlocks::getValue('font_weight'), 'bold', false); |
| 345 | + | |
| 346 | + // $fweight->output('group_start'); | |
| 395 | 347 | $admin->addField($fweight, 'group_start'); |
| 396 | 348 | |
| 397 | 349 | $fstyle = new maxField('checkbox'); |
| 398 | 350 | $fstyle->icon = 'dashicons-editor-italic'; |
| @@ -401,8 +353,10 @@ | ||
| 401 | 353 | $fstyle->name = 'font_style'; |
| 402 | 354 | $fstyle->value = 'italic'; |
| 403 | 355 | $fstyle->inputclass = 'check_button icon'; |
| 404 | 356 | $fstyle->checked = checked( maxBlocks::getValue('font_style'), 'italic', false); |
| 357 | + | |
| 358 | + //$fstyle->output('','group_end'); | |
| 405 | 359 | $admin->addField($fstyle, '', 'group_end'); |
| 406 | 360 | |
| 407 | 361 | $falign_left = new maxField('radio'); |
| 408 | 362 | $falign_left->icon = 'dashicons-editor-alignleft'; |
| @@ -411,8 +365,10 @@ | ||
| 411 | 365 | $falign_left->name = 'text_align'; |
| 412 | 366 | $falign_left->value = 'left'; |
| 413 | 367 | $falign_left->inputclass = 'check_button icon'; |
| 414 | 368 | $falign_left->checked = checked ( maxblocks::getValue('text_align'), 'left', false); |
| 369 | + | |
| 370 | + //$falign_left->output('group_start'); | |
| 415 | 371 | $admin->addField($falign_left, 'group_start'); |
| 416 | 372 | |
| 417 | 373 | $falign_center = new maxField('radio'); |
| 418 | 374 | $falign_center->icon = 'dashicons-editor-aligncenter'; |
| @@ -421,8 +377,10 @@ | ||
| 421 | 377 | $falign_center->name = 'text_align'; |
| 422 | 378 | $falign_center->value = 'center'; |
| 423 | 379 | $falign_center->inputclass = 'check_button icon'; |
| 424 | 380 | $falign_center->checked = checked( maxblocks::getValue('text_align'), 'center', false); |
| 381 | + | |
| 382 | + //$falign_center->output(); | |
| 425 | 383 | $admin->addField($falign_center); |
| 426 | 384 | |
| 427 | 385 | $falign_right = new maxField('radio'); |
| 428 | 386 | $falign_right->icon = 'dashicons-editor-alignright'; |
| @@ -431,8 +389,10 @@ | ||
| 431 | 389 | $falign_right->name = 'text_align'; |
| 432 | 390 | $falign_right->value = 'right'; |
| 433 | 391 | $falign_right->inputclass = 'check_button icon'; |
| 434 | 392 | $falign_right->checked = checked( maxblocks::getValue('text_align'), 'right', false); |
| 393 | + | |
| 394 | + //$falign_right->output('', array('group_end','end') ); | |
| 435 | 395 | $admin->addField($falign_right, '', array('group_end','end') ); |
| 436 | 396 | |
| 437 | 397 | // Padding - trouble |
| 438 | 398 | $ptop = new maxField('number'); |
| @@ -442,8 +402,10 @@ | ||
| 442 | 402 | $ptop->min = 0; |
| 443 | 403 | $ptop->inputclass = 'tiny'; |
| 444 | 404 | $ptop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Padding Top","maxbuttons") . '" >'; |
| 445 | 405 | $ptop->value = maxUtils::strip_px(maxBlocks::getValue('padding_top')); |
| 406 | + | |
| 407 | + //$ptop->output('start'); | |
| 446 | 408 | $admin->addField($ptop,'start'); |
| 447 | 409 | |
| 448 | 410 | $pright = new maxField('number'); |
| 449 | 411 | $pright->id = 'padding_right'; |
| @@ -451,8 +413,10 @@ | ||
| 451 | 413 | $pright->min = 0; |
| 452 | 414 | $pright->inputclass = 'tiny'; |
| 453 | 415 | $pright->before_input = '<img src="' . $icon_url . 'p_right.png" class="icon padding" title="' . __("Padding Right","maxbuttons") . '" >'; |
| 454 | 416 | $pright->value = maxUtils::strip_px(maxBlocks::getValue('padding_right')); |
| 417 | + | |
| 418 | + //$pright->output(); | |
| 455 | 419 | $admin->addField($pright); |
| 456 | 420 | |
| 457 | 421 | $pbottom = new maxField('number'); |
| 458 | 422 | $pbottom->id = 'padding_bottom'; |
| @@ -460,8 +424,10 @@ | ||
| 460 | 424 | $pbottom->min = 0; |
| 461 | 425 | $pbottom->inputclass = 'tiny'; |
| 462 | 426 | $pbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" class="icon padding" title="' . __("Padding Bottom","maxbuttons") . '" >'; |
| 463 | 427 | $pbottom->value = maxUtils::strip_px(maxBlocks::getValue('padding_bottom')); |
| 428 | + | |
| 429 | + //$pbottom->output(); | |
| 464 | 430 | $admin->addField($pbottom); |
| 465 | 431 | |
| 466 | 432 | $pleft = new maxField('number'); |
| 467 | 433 | $pleft->id = 'padding_left'; |
| @@ -469,8 +435,10 @@ | ||
| 469 | 435 | $pleft->min = 0; |
| 470 | 436 | $pleft->inputclass = 'tiny'; |
| 471 | 437 | $pleft->before_input = '<img src="' . $icon_url . 'p_left.png" class="icon padding" title="' . __("Padding Left","maxbuttons") . '" >'; |
| 472 | 438 | $pleft->value = maxUtils::strip_px(maxBlocks::getValue('padding_left')); |
| 439 | + | |
| 440 | + //$pleft->output('','end'); | |
| 473 | 441 | $admin->addField($pleft,'', 'end'); |
| 474 | 442 | |
| 475 | 443 | |
| 476 | 444 | // Text Color |
| @@ -483,8 +451,10 @@ | ||
| 483 | 451 | $fcolor->bindto = 'text_color_hover'; |
| 484 | 452 | $fcolor->copypos = 'right'; |
| 485 | 453 | $fcolor->right_title = $color_copy_move; |
| 486 | 454 | $fcolor->left_title = $color_copy_self; |
| 455 | + | |
| 456 | + // $fcolor->output('start'); | |
| 487 | 457 | $admin->addField($fcolor, 'start'); |
| 488 | 458 | |
| 489 | 459 | // Text Color Hover |
| 490 | 460 | $fcolor_hover = new maxField('color'); |
| @@ -496,8 +466,9 @@ | ||
| 496 | 466 | $fcolor_hover->bindto = $fcolor->id; |
| 497 | 467 | $fcolor_hover->copypos = 'left'; |
| 498 | 468 | $fcolor_hover->right_title = $color_copy_self; |
| 499 | 469 | $fcolor_hover->left_title = $color_copy_move; |
| 470 | + //$fcolor_hover->output('','end'); | |
| 500 | 471 | |
| 501 | 472 | $admin->addField($fcolor_hover, '','end'); |
| 502 | 473 | |
| 503 | 474 | // Dimension : width |
| @@ -506,10 +477,10 @@ | ||
| 506 | 477 | $field_width->name = 'button_width'; |
| 507 | 478 | $field_width->id = $field_width->name; |
| 508 | 479 | $field_width->inputclass = 'small'; |
| 509 | 480 | $field_width->min = 0; |
| 510 | - $field_width->after_input = __('px', 'maxbuttons'); | |
| 511 | 481 | $field_width->value= maxUtils::strip_px(maxBlocks::getValue('button_width')); // strippx? |
| 482 | + //$field_width->output('start'); | |
| 512 | 483 | |
| 513 | 484 | $admin->addField($field_width, 'start'); |
| 514 | 485 | |
| 515 | 486 | // Dimension : height |
| @@ -518,11 +489,10 @@ | ||
| 518 | 489 | $field_height->name = 'button_height'; |
| 519 | 490 | $field_height->id = $field_height->name; |
| 520 | 491 | $field_height->inputclass = 'small'; |
| 521 | 492 | $field_height->min = 0; |
| 522 | - $field_height->after_input = __('px', 'maxbuttons'); | |
| 523 | - $field_height->help = __('Width and Height are optional. When set to 0,button size will be determined by text size plus padding', 'maxbuttons'); | |
| 524 | 493 | $field_height->value= maxUtils::strip_px(maxBlocks::getValue('button_height')); // strippx? |
| 494 | + //$field_height->output('','end'); | |
| 525 | 495 | |
| 526 | 496 | $admin->addField($field_height, '', 'end'); |
| 527 | 497 | |
| 528 | 498 | // Description |
| @@ -537,16 +507,19 @@ | ||
| 537 | 507 | $field_desc->id = $field_desc->name; |
| 538 | 508 | $field_desc->esc_function = 'esc_textarea'; |
| 539 | 509 | $field_desc->value = maxBlocks::getValue('description') ; |
| 540 | 510 | $field_desc->placeholder = __('Brief explanation about how and where the button is used.','maxbuttons'); |
| 511 | + //$field_desc->output('start','end'); | |
| 541 | 512 | |
| 542 | 513 | $admin->addField($field_desc, 'start', 'end'); |
| 543 | 514 | |
| 544 | - $this->sidebar(); | |
| 545 | - $endblock = new maxField('block_end'); | |
| 546 | - $admin->addField($endblock); | |
| 515 | + $admin->display_fields(); | |
| 516 | + ?> | |
| 547 | 517 | |
| 548 | - } // admin_display | |
| 518 | + | |
| 519 | + </div> | |
| 520 | + </div> | |
| 521 | +<?php } // admin_display | |
| 549 | 522 | |
| 550 | 523 | } // class |
| 551 | 524 | |
| 552 | 525 | ?> |