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 | classes/admin-class.php +22 -235 7.116.28 View file →
@@ -43,9 +43,9 @@
43 43 }
44 44
45 45
46 46 // add a maxfield to be displayed on the admin.
47 - public function addfield($field, $start = '', $end = '')
47 + public function addfield( $field, $start = '', $end = '')
48 48 {
49 49 $field_id = isset($field->id) ? $field->id : $field->template . \rand(0,1000);
50 50
51 51 $field->publish = false; // Output fields via class - never output.
@@ -55,65 +55,11 @@
55 55 'end' => $end);
56 56 $this->fields = apply_filters('mb/editor/addfield', $this->fields, $field);
57 57
58 58 $this->defined_fields[] = $field_id;
59 - do_action('mb/editor/afterfield/'. $field_id, $field);
59 + do_action('mb/editor/afterfield/'. $field_id);
60 60 }
61 61
62 - /** Insert a field before or after a existing field
63 - *
64 - * @param String $insert_field Existing field to perform operation on
65 - * @param Object $field The new field to insert
66 - * @param String $start Start Template
67 - * @param String $end End template
68 - * @param String $op Insert before of after specified insert field
69 - */
70 - public function insertField($insert_field, $field, $start = 'start', $end = 'end', $op = 'before')
71 - {
72 - $insert_pos = 0;
73 -
74 - $this->addField($field, $start, $end); // add the field to the array
75 -
76 - foreach($this->fields as $field_id => $array)
77 - {
78 - if ($field_id == $insert_field)
79 - {
80 -
81 - break;
82 - }
83 - $insert_pos++;
84 - }
85 -
86 - // Find inserted field and remove it from array.
87 - $new_field_id = $field->id;
88 - $new_field_ar = $this->fields[$new_field_id];
89 - unset($this->fields[$new_field_id]);
90 -
91 - // Find position to insert new field
92 - // Yes this could be more efficient.
93 - $new_fields = array();
94 - $i = 0;
95 - foreach($this->fields as $field_id => $array)
96 - {
97 - if ($i == $insert_pos && $op == 'before')
98 - {
99 - $new_fields[$new_field_id] = $new_field_ar;
100 - }
101 - $new_fields[$field_id] = $array;
102 - if ($i == $insert_pos && $op == 'after')
103 - {
104 - $new_fields[$new_field_id] = $new_field_ar;
105 - }
106 - $i++;
107 - }
108 - $this->fields = $new_fields;
109 - }
110 -
111 - public function getFields()
112 - {
113 - return $this->fields;
114 - }
115 -
116 62 public function display_fields($clean = true, $return = false)
117 63 {
118 64 $fields = apply_filters('mb/display_fields', $this->fields);
119 65 $output = '';
@@ -294,29 +240,29 @@
294 240
295 241 return $return;
296 242 }
297 243
298 - static public function getAjaxButtons($post)
244 + static function getAjaxButtons()
299 245 {
300 246
301 247 $admin = self::getInstance();
302 248 $args = array();
303 249
304 - $paged = (isset($post["page"])) ? intval($post["page"]) : 1;
250 + $paged = (isset($_REQUEST["paged"])) ? intval($_REQUEST["paged"]) : 1;
305 251 if ($paged > 0)
306 252 $args["paged" ] = $paged;
307 253
308 - $button = MB()->getClass('button');
254 +
255 + $button = new MaxButton();
309 256 $buttons = $admin->getButtons($args);
310 257
311 - ob_start();
312 - echo "<div class='ajax-content'>";
258 + echo "<div id='maxbuttons'><div class='preview-buttons'>";
313 259
314 -// echo '<div class="tablenav top"> ';
260 + echo '<div class="tablenav top"> ';
315 261 echo "<span class='hint'>" . __('Click on a button to select it and add the shortcode to the editor', 'maxbuttons') . "</span>";
316 - do_action('mb-display-pagination', $args, 'top');
262 + do_action('mb-display-pagination', $args);
317 263 echo '<span class="loading"></span>';
318 -// echo '</div>';
264 + echo '</div>';
319 265
320 266
321 267 if (count($buttons) == 0)
322 268 {
@@ -321,10 +267,10 @@
321 267 if (count($buttons) == 0)
322 268 {
323 269
324 270 $url = admin_url('admin.php?page=maxbuttons-controller&action=edit');
325 - echo "<h3 class='nobuttons-header'>" . __("You didn't create any buttons yet!","maxbuttons") . "</h3>";
326 - echo "<p class='nobuttons-link'>" . sprintf(__("Click %shere%s to add one", "maxbuttons"),
271 + echo "<p><strong>" . __("You didn't add any buttons yet!","maxbuttons") . "</strong></p>";
272 + echo "<P>" . sprintf(__("Click %shere%s to add one", "maxbuttons"),
327 273 "<a href='$url' target='_blank'>", "</a>") . "</strong></p>";
328 274
329 275 }
330 276
@@ -332,191 +278,32 @@
332 278 {
333 279
334 280 $button_id = $b["id"];
335 281 $button->set($button_id);
336 - echo "<div class='button-list button-select' data-button='$button_id'>";
337 - echo "<span class='button-id'> ";
282 + echo "<div class='button-row button-select' data-button='$button_id'>";
283 + echo "<span class='col col_insert'> ";
338 284
339 285 echo "<span class='small'>[ID: $button_id ]</span>
340 286 </span> ";
341 287
342 - echo "<span class='button-preview'><div class='shortcode-container'>";
288 + echo "<span class='col col_button'><div class='shortcode-container'>";
343 289 $button->display(array("mode" => "preview", "load_css" => "inline" ));
344 290 echo "</div></span>";
345 - echo "<span class='button-name'>" . $button->getName() . "</span>";
291 + echo "<span class='col col_name'>" . $button->getName() . "</span>";
346 292 echo "</div>";
347 293 }
348 - //echo '<div class="tablenav bottom"> ';
349 - do_action('mb-display-pagination', $args, 'bottom');
294 + echo '<div class="tablenav bottom"> ';
295 + do_action('mb-display-pagination', $args);
350 296 echo '<span class="loading"></span>';
351 - //echo '</div>';
297 + echo '</div>';
352 298
353 299
354 - echo "</div>";
355 - echo "<p style='height:80px;'>&nbsp;</p>";
300 + echo "</div></div>";
301 + echo "<p>&nbsp;</p>";
356 302
357 - $output = ob_get_contents();
358 - ob_end_clean();
359 -
360 - $result = array('output' => $output,
361 - 'action' => 'buttons_load');
362 -
363 - echo json_encode($result);
364 -
365 303 exit();
366 304
367 305 }
368 -
369 -
370 - static public function mediaShortcodeOptions($post)
371 - {
372 - $button_id = isset($post['button_id']) ? intval($post['button_id']) : false;
373 -
374 - $result = array('output' => '',
375 - 'action' => 'shortcode_options');
376 -
377 - $button = MB()->getClass("button");
378 - $button->set($button_id);
379 -
380 - //$data = $button->getd
381 -
382 - $data = array(
383 - 'url' => maxBlocks::getValue('url'),
384 - 'text' => maxBlocks::getValue('text'),
385 - 'new_window' => maxBlocks::getValue('new_window'),
386 - 'nofollow' => maxBlocks::getValue('nofollow'),
387 - 'link_title' => maxBlocks::getValue('link_title'),
388 - );
389 -
390 - // hook spec. qtrans.
391 - $mode = 'preview';
392 - $preview = true;
393 - $compile = false;
394 - $data = apply_filters('mb/button/data_before_display', $data, $mode, array('preview' => $preview, 'compile' => $compile) );
395 -
396 - $admin = self::getInstance();
397 - $shortcode_data = array(); // data array to build shortcodes and check default values
398 -
399 - $display_args = array('echo'=> false, 'load_css' => 'inline');
400 - $preview = new maxField('generic');
401 - $preview->name = 'button-preview';
402 - $preview->content = '<h3>' . __('Shortcode Options') . '</h3>
403 - <p>' . $button->display($display_args) . '</p>
404 - <p>' . __('Change the options to add shortcode attributes. ', 'maxbuttons') . '</p>';
405 -
406 - $admin->addField($preview, 'start','end');
407 -
408 - $url = new maxField('text');
409 - $url->id = 'shortcode_url';
410 - $url->name = $url->id;
411 - $url->placeholder = 'http://';
412 - $url->label = __('Button URL', 'maxbuttons');
413 - $url->value = $data['url'];
414 - $shortcode_data[] = array(
415 - 'name' => $url->name,
416 - 'original' => $url->value,
417 - 'shortcode' => 'url',
418 - );
419 -
420 - $admin->addField($url, 'start','end');
421 -
422 - $text = new maxField('text');
423 - $text->id = 'shortcode_text';
424 - $text->name = $text->id;
425 - $text->label = __('Button Text', 'maxbuttons');
426 - $text->value = $data['text'];
427 - $shortcode_data[] = array(
428 - 'name' => $text->name,
429 - 'original' => $text->value,
430 - 'shortcode' => 'text',
431 - );
432 -
433 - $admin->addField($text, 'start', 'end');
434 -
435 - $more = new maxField('generic');
436 - $more->name = 'more';
437 - $more->content = '<div class="more-options"><a href="#">' . __('More Options', 'maxbuttons') . '</a></div>';
438 -
439 - $admin->addField($more, 'start', 'end');
440 -
441 - $new_window = new maxField('checkbox');
442 - $new_window->id = 'shortcode_window';
443 - $new_window->name = $new_window->id;
444 - $new_window->label = __('Open in New Window', 'maxbuttons');
445 - $new_window->value = 1;
446 - $new_window->main_class = 'option more-field';
447 - $new_window->checked = checked( $data['new_window'], 1, false);
448 - $shortcode_data[] = array(
449 - 'name' => $new_window->name,
450 - 'original' => ( $data['new_window'] == 1) ? true : false,
451 - 'shortcode' => 'window',
452 - 'checked' => 'new',
453 - 'unchecked' => 'same',
454 - );
455 -
456 - $admin->addField($new_window, 'start', 'end');
457 -
458 - $ffollow = new maxField('checkbox');
459 - $ffollow->label = __('Use rel="nofollow"', 'maxbuttons');
460 - $ffollow->value = 1;
461 - $ffollow->name = 'shortcode_nofollow';
462 - $ffollow->id = $ffollow->name;
463 - $ffollow->main_class = 'option more-field';
464 - $ffollow->checked = checked( $data['nofollow'] , 1, false);
465 - $shortcode_data[] = array(
466 - 'name' => $ffollow->name,
467 - 'original' => ( $data['nofollow'] == 1) ? true : false,
468 - 'shortcode' => 'nofollow',
469 - 'checked' => 'true',
470 - 'unchecked' => 'false',
471 - );
472 -
473 -
474 - $admin->addField($ffollow, 'start','end');
475 -
476 - $field_title = new maxField('text');
477 - $field_title->label = __('Button Tooltip', 'maxbuttons');
478 - $field_title->name = 'shortcode_link_title'; // title is too generic
479 - $field_title->id = $field_title->name;
480 - $field_title->main_class = 'option more-field';
481 - $field_title->value = $data['link_title'];
482 -
483 - $shortcode_data[] = array(
484 - 'name' => $field_title->name,
485 - 'original' => $field_title->value,
486 - 'shortcode' => 'linktitle',
487 - );
488 -
489 - $admin->addField($field_title, 'start','end');
490 -
491 - $class = new maxField();
492 - $class->id = 'shortcode_extra_classes';
493 - $class->name = $class->id;
494 - $class->label = __("Extra classes","maxbuttons");
495 - $class->value = '';
496 - $class->main_class = 'option more-field';
497 -
498 - $shortcode_data[] = array(
499 - 'name' => $class->name,
500 - 'original' => $class->value,
501 - 'shortcode' => 'extraclass',
502 - );
503 -
504 - $admin->addField($class, 'start', 'end');
505 -
506 - $shortcode_data = apply_filters('mb/media/shortcode_data', $shortcode_data);
507 -
508 - $result['output'] = '<div class="ajax-content shortcode-options">' . $admin->display_fields(true,true) . '</div>';
509 - $result['shortcodeData'] = $shortcode_data;
510 - $result['button_id'] = $button_id;
511 -
512 - echo json_encode($result);
513 -
514 - exit();
515 -
516 - }
517 -
518 -
519 306 function get_header($args =array() )
520 307 {
521 308 $defaults = array(
522 309 "tabs_active" => false,
@@ -572,9 +359,9 @@
572 359 if (! is_dir($dir))
573 360 return false;
574 361
575 362 $file = fopen( trailingslashit($dir) . "/maxbuttons.log", "a+");
576 - $now = new \DateTime();
363 + $now = new DateTime() ;
577 364 $now_format = $now->format("d/M/Y H:i:s");
578 365
579 366 $write_string = "[" . $now_format . "] $action - $message ( $caller )";
580 367 fwrite($file, $write_string);