PluginProbe
Social Share Buttons / 1.1.1
Social Share Buttons v1.1.1
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / classes / blocks / display_block.php

display_block.php in Social Share Buttons 1.1.1, at classes/blocks/display_block.php

1,000 lines 28.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 use \MaxButtons\maxField as maxField;
6 use \MaxButtons\maxBlocks as maxBlocks;
7
8 $collectionBlock["display"] = array('class' => "displayBlock",
9 'order' => 25);
10
11 class displayBlock extends block
12 {
13 protected $blockname = "display";
14 protected $fields = array(
15 'display_page' => array('default' => 'hidden'),
16 'display_page_options' => array('default' => array()),
17 'display_post' => array('default' => 'hidden'),
18 'display_post_options' => array('default' => array()),
19 'display_homepage' => array('default' => 'hidden'),
20 'display_homepage_options' => array('default' => array()),
21 'display_archive' => array('default' => 'hidden'),
22 'display_archive_options' => array('default' => array()),
23 );
24
25 /*protected $meta_fields = array(
26 'display_here' => array('default' => 1 )
27 );
28 */
29
30 /*
31 function __construct()
32 {
33
34 }
35 */
36
37 function save_fields($data, $post)
38 {
39 $data = parent::save_fields($data, $post);
40 $blockdata = $data[$this->blockname];
41
42 $post_types = $this->get_post_types();
43
44 $save_global = array('display_page', 'display_post', 'display_homepage', 'display_archive');
45 $save_options = array('display_page_options', 'display_post_options', 'display_homepage_options', 'display_archive_options');
46
47 foreach($post_types as $post_type)
48 {
49 if (isset($post['display_' . $post_type]))
50 {
51 $field_name = 'display_' . $post_type;
52
53 $display = sanitize_text_field($post[$field_name]);
54 $options = isset($post[$field_name . '_options']) ? $post['display_' . $post_type . '_options'] : array();
55
56 $blockdata[$field_name] = $display;
57 $blockdata[$field_name . '_options'] = $options;
58
59 if (in_array($field_name, $save_global) === false) {
60 $save_global[] = $field_name;
61 }
62 if ( in_array($field_name . '_options', $save_options) === false)
63 {
64 $save_options[] = $field_name . '_options';
65 }
66
67 }
68
69 }
70
71 foreach($save_global as $field_name)
72 {
73
74 $data[$field_name] = $blockdata[$field_name];
75 unset($blockdata[$field_name]);
76 }
77
78 foreach ($save_options as $option)
79 {
80
81 if ( is_string($blockdata[$option]) && strlen($blockdata[$option]) > 0)
82 {
83 $blockdata[$option] = json_decode($blockdata[$option], true);
84 }
85 }
86
87 $data[$this->blockname] = $blockdata;
88
89
90
91 return $data;
92
93 }
94
95 /** Get usable, front-end, custom post types **/
96 public function get_post_types()
97 {
98 return \get_post_types(
99 array('public' => true,
100 '_builtin' => false,
101 )
102 );
103
104 }
105
106 public function parseCSS($css, $args)
107 {
108 $blockdata = $this->data[$this->blockname];
109 //$button_spacing = $this->data["button_spacing"];
110
111 $hook = $this->collection->getHook();
112
113 $options = isset($blockdata[$hook . "_options"]) ? $blockdata[$hook . '_options'] : array();
114 $display = isset($this->data[$hook]) ? $this->data[$hook] : 'hidden';
115
116 //$position_x = isset($options['position_x']) ? $options['position_x'] : 'auto';
117 //$position_y = isset($options['position_y']) ? $options['position_y'] : 'auto';
118
119 $position = isset($options['position']) ? $options['position'] : false;
120
121 $fixed = isset($options['fixed_position'] ) ? $options['fixed_position'] : false;
122
123 $orientation = $this->collection->orientation;
124 $is_static = $this->collection->is_static;
125 $is_post = $this->collection->is_post;
126
127 $css["mb-item"]["normal"]["float"] = 'left';
128 // Decide which auto values go with the default settings of the other dimensions.
129
130 if ($position)
131 {
132 list($position_y, $position_x) = explode("_", $position);
133
134 }
135 else {
136 if ($is_static)
137 {
138 $position_x = 'left';
139 $position_y = 'center';
140 }
141 else
142 {
143 $position_x = 'center';
144 $position_y = false;
145 }
146
147 }
148
149 switch($orientation)
150 {
151 case "horizontal":
152 $css["mb-item:last-child"]["normal"]["margin-right"] = "0";
153 break;
154
155 case "vertical";
156 $css["mb-item"]["normal"]["clear"] = "both";
157 break;
158
159 }
160
161 if ($args["preview"] == true)
162 return $css; // don't process move than this in preview.
163
164 if ($is_static) // static options
165 {
166 // if ($orientation == 'vertical')
167 $css['maxsocial']['normal']['width'] = 'auto';
168
169 if ($fixed == 1)
170 $css['maxsocial']['normal']['position'] = 'fixed';
171 else
172 $css['maxsocial']['normal']['position'] = 'absolute';
173
174
175 switch($position_x)
176 {
177 case "left":
178 case "right":
179 // left or right
180 $css["maxsocial"]["normal"][$position_x] = '0';
181 break;
182
183 case "center":
184 $css['maxsocial']['normal']['left'] = '50%';
185 $css['maxsocial']['normal']['transform'] = 'translateX(-50%)';
186 break;
187 }
188
189 switch($position_y)
190 {
191 case "center":
192 $css["maxsocial"]["normal"]["top"] = "50%";
193 if ( isset($css['maxsocial']['normal']['transform'])) // set by x
194 {
195 $css['maxsocial']['normal']['transform'] = 'translate(-50%,-50%)';
196 }
197 else
198 $css["maxsocial"]["normal"]["transform"] = "translateY(-50%)";
199 break;
200 case 'top':
201 $css['maxsocial']['normal']['top'] = 0;
202 break;
203 case "bottom":
204 $css["maxsocial"]["normal"]["bottom"] = "0";
205 break;
206 }
207
208
209 } // is_static
210
211 return $css;
212 }
213
214 protected function expert_admin()
215 {
216 $admin = mbSocial()->admin();
217
218 $data = $this->data;
219 $blockdata = $this->data[$this->blockname];
220
221 /*
222 $staticIcons = array(
223 'auto' => 'icon_auto.png',
224 'left' => 'icon_posleft.png',
225 'right' => 'icon_posright.png',
226 'center' => 'icon_poscenter.png',
227 'top' => 'icon_postop.png',
228 'bottom' => 'icon_posbottom.png',
229 'horizontal' => 'icon_horizontal.png',
230 'vertical' => 'icon_vertical.png',
231 );
232 */
233 $icon_url = MBSocial()->get_plugin_url() . 'images/icons/';
234 /*$option_icons = array(
235 'hidden' => 'icon_manual.png',
236 'before' => 'icon_before.png',
237 'after' => 'icon_after.png',
238 'after-before' => 'icon_both.png',
239 'static' => 'icon_absolute.png'
240 ); */
241
242 $options = array(
243 'hidden' => __('Manual / Do not show', 'mbsocial'),
244 'before' => __('Before post content','mbsocial'),
245 'after' => __('After post content', 'mbsocial'),
246 'after-before' => __('Before and after the post content', 'mbsocial'),
247 'static' => __('Absolute Position', 'mbsocial'),
248 );
249
250 $conditional_options = $options;
251 unset($conditional_options['hidden']); // all minus hidden
252 $conditional_options = array_keys($conditional_options);
253
254
255 $option_button = new maxField('button');
256 $option_button->modal = 'modal_options';
257 $option_button->button_label = __("Options",'mbsocial');
258 $option_button->name = 'options';
259 $option_button->inputclass = 'maxmodal';
260
261 $gen = new maxField('generic');
262 $title_off = __('Off / Manual - Hide on this view. You can add it manually via the shortcode', 'mbsocial');
263 $title_content = __('Display around the post content', 'mbsocial');
264 $title_float = __('Display static / floating at the screen. Configure position via options', 'mbsocial');
265
266 $gen->content = '<span title="' . $title_off . '">' . __('Off', 'mbsocial') . '</span>
267 <span title="' . $title_content . '">' . __('Content','mbsocial') . '</span>
268 <span title="' . $title_float . '">' . __('Float','mbsocial') . '</span>';
269
270 $gen->name = 'display_heading';
271 $admin->addField($gen,'start','end');
272
273 $genrow = new maxField('generic');
274 $genrow->content = '<span>Top</span><span>Bottom</span><span>Both</span>';
275 $genrow->name = 'display_rowhead';
276
277 $admin->addField($genrow, 'start','end');
278
279 // ** HOMEPAGE
280 $fspacer = new maxField('spacer');
281 $fspacer->label = __('Homepage', 'mbsocial');
282 $fspacer->name = 'spacer';
283 $fspacer->main_class = 'option display_group';
284
285 $admin->addField($fspacer, 'start');
286
287 $i =0;
288 foreach($options as $option => $label)
289 {
290 $display = new maxField('radio');
291 $display->id = 'radio_display_homepage_' . $option;
292 $display->name = 'display_homepage';
293 $display->title = $label;
294 $display->value = $option;
295
296 //$display->image = $icon_url . $option_icons[$option];
297 $display->custom_icon = 'display_icon ' . $option;
298
299 if (isset($data[$display->name]))
300 $display->checked = checked ( $data[$display->name], $option, false);
301 $display->inputclass = 'check_button icon';
302
303 $start = ($i == 0) ? 'group_start' : '';
304 $end = ($i == count($options)-1 ) ? 'group_end' : '';
305 $admin->addField($display, $start, $end);
306 $i++;
307 }
308
309 $hidden = new maxField('hidden');
310 $hidden->id = 'display_homepage_options';
311 $hidden->name = $hidden->id;
312 if (isset($blockdata['display_homepage_options']))
313 $hidden->value = htmlentities(json_encode($blockdata['display_homepage_options']) );
314
315 $admin->addField($hidden, '','');
316
317 $homepage_button = clone $option_button;
318 $homepage_button->id = 'option_homepage';
319 $homepage_button->conditional = htmlentities(json_encode(array('target' => $display->name, 'values' => $conditional_options)));
320 $admin->addField( $homepage_button, '', 'end');
321
322 $fspacer = new maxField('spacer');
323 $fspacer->name = 'spacer';
324 $fspacer->main_class = 'option display_group';
325 $fspacer->label = __('Pages', 'mbsocial');
326
327 $admin->addField($fspacer, 'start', '');
328
329 $i = 0;
330 foreach($options as $option => $label)
331 {
332 $display = new maxField('radio');
333 $display->id = 'radio_display_page_' . $option;
334 $display->name = 'display_page';
335 $display->title = $label;
336 $display->value = $option;
337 // $display->label = ($i == 0) ? __('Pages') : '';
338
339
340 // $display->image = $icon_url . $option_icons[$option];
341 $display->custom_icon = 'display_icon ' . $option;
342
343 if (isset($data[$display->name]))
344 $display->checked = checked ( $data[$display->name], $option, false);
345
346 $display->inputclass = 'check_button icon';
347
348 $start = ($i == 0) ? 'group_start' : '';
349 $end = ($i == count($options)-1) ? 'group_end' : '';
350 $admin->addField($display, $start, $end);
351 $i++;
352 }
353
354 /*
355 $display = new maxField('option_select');
356 $display->publish = false;
357 $display->label = __('Pages', 'mbsocial');
358 $display->id = 'display_page';
359 $display->name = $display->id;
360 $display->selected = isset($data[$display->id]) ? $data[$display->id] : '';
361 $display->options = $options;
362 $display->main_class = 'option display_group';
363
364 $admin->addField($display, 'start','');
365 */
366
367 $pages_button = clone $option_button;
368 $pages_button->id = 'option_page';
369 $pages_button->conditional = htmlentities(json_encode(array('target' => $display->name, 'values' => $conditional_options)));
370
371 $hidden = new maxField('hidden');
372 $hidden->id = 'display_page_options';
373 $hidden->name = $hidden->id;
374 if ( isset($blockdata['display_page_options']))
375 $hidden->value = htmlentities(json_encode($blockdata['display_page_options']) );
376 $admin->addField( $hidden, '','');
377
378 $admin->addField($pages_button, '','end');
379
380
381 // ** POSTS
382 $fspacer = new maxField('spacer');
383 $fspacer->label = __('Posts', 'mbsocial');
384 $fspacer->name = 'spacer';
385 $fspacer->main_class = 'option display_group';
386
387 $admin->addField($fspacer, 'start');
388
389 $i = 0;
390 foreach($options as $option => $label)
391 {
392 $display = new maxField('radio');
393 $display->id = 'radio_display_post_' . $option;
394 $display->name = 'display_post';
395 $display->title = $label;
396 $display->value = $option;
397
398 //$display->image = $icon_url . $option_icons[$option];
399 $display->custom_icon = 'display_icon ' . $option;
400
401 if (isset($data[$display->name]))
402 $display->checked = checked ( $data[$display->name], $option, false);
403 $display->inputclass = 'check_button icon';
404
405 $start = ($i == 0) ? 'group_start' : '';
406 $end = ($i == count($options)-1) ? 'group_end' : '';
407 $admin->addField($display, $start, $end);
408 $i++;
409 }
410 /*
411 $display = new maxField('option_select');
412 $display->publish = false;
413 $display->label = __('Posts', 'mbsocial');
414 $display->id = 'display_post';
415 $display->name = $display->id;
416 $display->selected = isset($data[$display->id]) ? $data[$display->id] : '';
417 $display->options = $options;
418 $display->main_class = 'option display_group';
419
420 $admin->addField($display, 'start', '');
421 */
422 $posts_button = clone $option_button;
423 $posts_button->id = 'option_post';
424 $posts_button->conditional = htmlentities(json_encode(array('target' => $display->name, 'values' => $conditional_options)));
425
426 $hidden = new maxField('hidden');
427 $hidden->id = 'display_post_options';
428 $hidden->name = $hidden->id;
429 if (isset($blockdata['display_post_options']))
430 $hidden->value = htmlentities(json_encode($blockdata['display_post_options']) );
431 $admin->addField($hidden, '','');
432
433 $admin->addField( $posts_button, '','end');
434
435
436 // ** ARCHIVES **
437 $fspacer = new maxField('spacer');
438 $fspacer->name = 'spacer';
439 $fspacer->main_class = 'option display_group';
440 $fspacer->label = __('Archive and Categories', 'mbsocial');
441 $admin->addField($fspacer, 'start');
442
443 $i = 0;
444 foreach($options as $option => $label)
445 {
446 $display = new maxField('radio');
447 $display->id = 'radio_display_archive_' . $option;
448 $display->name = 'display_archive';
449 $display->title = $label;
450 $display->value = $option;
451
452 // $display->image = $icon_url . $option_icons[$option];
453 $display->custom_icon = 'display_icon ' . $option;
454
455 if (isset($data[$display->name]))
456 $display->checked = checked ( $data[$display->name], $option, false);
457 $display->inputclass = 'check_button icon';
458
459 $start = ($i == 0) ? 'group_start' : '';
460 $end = ($i == count($options)-1 ) ? 'group_end' : '';
461 $admin->addField($display, $start, $end);
462 $i++;
463 }
464 /*$display = new maxField('option_select');
465 $display->publish = false;
466 $display->label = __('Archive and Categories', 'mbsocial');
467 $display->id = 'display_archive';
468 $display->name = $display->id;
469 $display->selected = isset($data[$display->id]) ? $data[$display->id] : '';
470 $display->options = $options;
471 $display->main_class = 'option display_group';
472
473 $admin->addField( $display, 'start', '');
474 */
475 $archive_button = clone $option_button;
476 $archive_button->id = 'option_archive';
477 $archive_button->conditional = htmlentities(json_encode(array('target' => $display->name, 'values' => $conditional_options)));
478
479 $hidden = new maxField('hidden');
480 $hidden->id = 'display_archive_options';
481 $hidden->name = $hidden->id;
482 if (isset($blockdata['display_archive_options']))
483 $hidden->value = htmlentities(json_encode($blockdata['display_archive_options']) );
484
485 $admin->addField($hidden, '','');
486
487 $admin->addField($archive_button, '', 'end');
488
489 $post_types = $this->get_post_types();
490
491
492 if (count($post_types) > 0)
493 {
494 $spacer = new maxField('spacer');
495 $spacer->label = __('Custom Post Types', 'mbsocial');
496 $spacer->id = 'spacer_custom';
497 $spacer->name = $spacer->id;
498
499 $admin->addField($spacer, 'start', 'end');
500
501 if (! Install::isPRO() ) {
502 $spacer_pro = new maxField('spacer');
503 $spacer_pro->id = 'display_no_pro';
504 $spacer_pro->label = $admin->getProMessage();
505 $spacer_pro->name = $spacer_pro->id;
506
507 $admin->addField($spacer_pro,'start', 'end');
508 }
509 }
510
511 // Custom Post Types
512 foreach ($post_types as $post_type)
513 {
514
515 $fspacer = new maxField('spacer');
516 $fspacer->label = ucfirst($post_type);
517 $fspacer->name = 'spacer';
518 $fspacer->main_class = 'option display_group';
519 $admin->addField($fspacer, 'start');
520
521 $option_value = isset($data['display_' . $post_type]) ? $data['display_' . $post_type] : 'hidden';
522
523 $i = 0;
524 foreach($options as $option => $label)
525 {
526
527 $display = new maxField('radio');
528 $display->id = 'radio_display_' . $post_type . '_' . $option;
529 $display->name = 'display_' . $post_type;
530 $display->title = $label;
531 $display->value = $option;
532 // $display->image = $icon_url . $option_icons[$option];
533 $display->custom_icon = 'display_icon ' . $option;
534
535 $display->checked = checked ( $option_value, $option, false);
536 $display->inputclass = 'check_button icon';
537
538 if (! Install::isPRO() ) {
539 $display->disabled = true;
540 $display->inputclass = 'check_button icon disabled';
541
542
543 }
544
545 $start = ($i == 0) ? 'group_start' : '';
546 $end = ($i == count($options)-1 ) ? 'group_end' : '';
547 $admin->addField($display, $start, $end);
548 $i++;
549 }
550
551 /*
552 $display = new maxField('option_select');
553 $display->id = 'display_' . $post_type;
554 $display->name = $display->id;
555 $display->label = ucfirst($post_type);
556 $display->selected = isset($data[$display->id]) ? $data[$display->id] : '';
557 $display->options = $options;
558 $display->main_class = 'option display_group ' . $display->id;
559 */
560
561 // $admin->addField($display, 'start', '');
562
563 $display_button = clone $option_button;
564 $display_button->id = 'option_' . $post_type;
565 $display_button->name = $display_button->id;
566 $display_button->conditional = htmlentities(json_encode(array('target' => $display->name, 'values' => $conditional_options)));
567
568 $hidden = new maxField('hidden');
569 $hidden->id = 'display_' . $post_type . '_options';
570 $hidden->name = $hidden->id;
571 if ( isset($blockdata['display_' . $post_type . '_options']))
572 $hidden->value = htmlentities(json_encode($blockdata['display_' . $post_type . '_options']));
573
574 $admin->addField( $hidden, '','');
575 $admin->addField( $display_button, '', 'end');
576
577
578 }
579
580 $admin->display_fields();
581
582 }
583
584 /*protected function getDisplayRules()
585 {
586 $data = $this->data;
587 $blockdata = $this->data[$this->blockname];
588
589 return array();
590 } */
591
592 protected function addRule($args)
593 {
594 $rule = array(
595 'hook' => '',
596 'display' => 'hidden',
597 'orientation' => '',
598 'position' => '',
599 'fixed' => '',
600 'share_setting' => 'current-post',
601 'custom_url' => '',
602 );
603
604 $rule = wp_parse_args($args, $rule);
605 return $rule;
606 }
607
608
609 /** Just simple for whom? **/
610 protected function simple_admin()
611 {
612
613 $admin = mbSocial()->admin();
614
615 $data = $this->data;
616 $blockdata = $this->data[$this->blockname];
617
618 $rules = $this->getDisplayRules();
619
620 if(count($rules) == 0)
621 {
622 $rule = $this->addRule(array(
623 'hook' => 'all',
624 'display' => 'static',
625 'orientation' => 'vertical',
626 'fixed' => true,
627
628 ));
629 $rules[] = $rule;
630 }
631
632
633 $label = new maxField('spacer');
634 $label->label = __('Label!', 'mbsocial');
635 $label->id = 'label';
636
637 $admin->addField($label, 'start');
638
639 foreach ($rules as $rule)
640 {
641 $display = $rule['display'];
642 $hook = $rule['hook'];
643
644 $output = sprintf('On %s this will show the button %s ', $hook, $display);
645
646
647 }
648
649 $rfield = new maxField('generic');
650 $rfield->id = 'rule_1';
651 $rfield->content = $output;
652
653 $admin->addField($rfield,'','end');
654
655 $admin->display_fields();
656 ?>
657 <p><h4>
658
659 On the <strong>Homepage</strong> this will show <strong>Before the content</strong>
660
661 <i>Remove</i>
662
663 <p>
664
665 <p> <h3> <a>Add a display Rule</a> </h3>
666 </p>
667
668 <p>I want this to show at the <select>
669 <option>Homepage</option>
670 <option>Pages</option>
671 <option>Posts</option>
672 <option>Custom Post Type</option>
673 </select>
674 section. Show it
675 <select><option>Before the content</option>
676 <option>After the content</option>
677 <option>Both before and after the cotnent</option>
678 <option class='selected'>Separate from the content</option>
679 </select>
680
681 </p>
682 <p>The position of the separated content will be <strong>Left </strong>
683 <strong>Top</strong>
684 </p>
685
686 <p> The shared URL will be the one of the page / something else
687 <input type='text'>
688 <input type="button" value="Do it" class="button-primary">
689 </p>
690
691 <?php
692
693
694 }
695
696 /** Admin() **/
697 public function admin()
698 {
699 $admin = mbSocial()->admin();
700
701 $data = $this->data;
702 $blockdata = $this->data[$this->blockname];
703
704 $orientation_options = array('auto' => __('Auto','mbsocial'),
705 'horizontal' => __('Horizontal','mbsocial'),
706 'vertical' => __('Vertical', 'mbsocial'),
707 );
708
709 $static_options = array(
710 // 'auto' => __('Auto', 'mbsocial'),
711 'left' => __('Left', 'mbsocial'),
712 'center' => __('Center', 'mbsocial'),
713 'right' => __('Right', 'mbsocial'),
714
715 // 'bottom' => __('Bottom', 'mbsocial'),
716 );
717
718 $staticpos_options = array(
719 // 'auto' => __('Auto', 'mbsocial'),
720 'top' => __('Top', 'mbsocial'),
721 'center' => __('Center', 'mbsocial'),
722 'bottom' => __('Bottom', 'mbsocial'),
723 );
724
725 $collection_id = $this->collection->getID();
726
727 if ($collection_id > 0)
728 $display_id = $collection_id;
729 else
730 $display_id = '*id*';
731
732 ?>
733 <div class='help-side'>
734 <h3><?php _e('Display Options', 'mbsocial') ?></h3>
735 <p>You can control where share buttons will appear by section of the site, like posts, pages, categories and custom post types</p>
736
737 <p><b>Manual / Off:</b> Use [maxsocial id="<?php echo $display_id ?>"] in your post content where you would like social sharing to appear</p>
738
739 <p><b>Content :</b> The buttons will display before or after your main post content, or both. </p>
740
741 <p><b>Float: </b> The buttons will display detached from the movement of content on the screen. This will allow you to position them on a fixed position. </p>
742
743 <p>Some settings have options which are revealed after clicking that option's button</p>
744 </div>
745
746 <div id='displayBlock' class='options display option-container'>
747 <div class='title'><?php _e('Display Options', 'mbsocial'); ?></div>
748 <div class='inside'>
749 <?php // [Simple] [Expert] ?>
750 <?php
751 // ** PAGES **
752 $i = 0;
753
754 $interface_option = 'simple';
755
756 // if ($interface_option == 'expert')
757 $this->expert_admin();
758
759 /*else {
760 $this->simple_admin();
761
762 } */
763 ?>
764
765 </div> <!-- inside -->
766 </div> <!-- option-container -->
767
768 <div id='modal_options' class='maxmodal-data' data-load='window.maxFoundry.maxSocial.displayOptions'>
769 <div class='title'><?php _e('Options', 'mbsocial'); ?></div>
770 <div class='content '>
771 <div class='display_modal wrapper'>
772
773 <div class='post_options'>
774
775 <?php
776 $staticIcons = array(
777 'auto' => 'icon_auto.png',
778 'left' => 'icon_posleft.png',
779 'right' => 'icon_posright.png',
780 'center' => 'icon_poscenter.png',
781 'top' => 'icon_postop.png',
782 'bottom' => 'icon_posbottom.png',
783 'horizontal' => 'icon_horizontal.png',
784 'vertical' => 'icon_vertical.png',
785 );
786 $icon_url = MBSocial()->get_plugin_url() . 'images/icons/';
787
788 $orsp = new maxField('spacer');
789 $orsp->name = 'or_spacer';
790 $orsp->label = __('Orientation of the buttons');
791
792 $admin->addField($orsp, 'start');
793
794
795 $or = new maxField('radio');
796 $or->id = 'orientation_horizontal';
797 $or->name = 'orientation';
798 $or->title = __('Horizontal', 'mbsocial');
799 $or->value = 'horizontal';
800 // $or->image = $icon_url . $staticIcons['horizontal'];
801 $or->custom_icon = 'display_icon horizontal';
802
803
804 // $or->checked =
805 $or->inputclass = 'check_button icon';
806
807
808 $admin->addField($or, '', '');
809
810 $orv = clone $or;
811 $orv->id = 'orientation_vertical';
812 $orv->title = __('Vertical', 'mbsocial');
813 $or->value = 'vertical';
814 // $or->image = $icon_url . $staticIcons['vertical'];
815 $or->custom_icon = 'display_icon vertical';
816
817
818 $admin->addField($orv, '', 'end');
819
820 $admin->display_fields();
821
822 ?>
823 </div>
824 <div class='content_options'>
825 <?php
826
827 $spacer = new maxField('spacer');
828 $spacer->name = 'spacer';
829 //$spacer->main_class = 'pos_options';
830 $spacer->label = __('Alignment', 'mbsocial');
831 //$admin->addField($spacer, 'start','');
832
833 $i = 0;
834 foreach($static_options as $option => $label)
835 {
836 $posopt = new maxField('radio');
837 $posopt->id = 'position_x_' . $option;
838 $posopt->name = 'position_x';
839 $posopt->title = $label;
840 $posopt->value = $option;
841 //$posopt->image = $icon_url . $staticIcons[$option];
842 //$postopt->custom_icon = 'display_icon ' . $option;
843
844 //default
845 $posopt->checked = checked ( $option, 'auto', false);
846 $posopt->inputclass = 'check_button icon';
847 $end = ($i == count($static_options)-1) ? 'end' : '';
848
849 //$admin->addField($posopt, '',$end);
850 $i++;
851 }
852 /* This is note possible due to margins being in use . */
853 //$admin->display_fields();
854
855 ?>
856
857 </div>
858
859 <div class='static_options'>
860
861 <?php
862 /*
863 $spacer = new maxField('spacer');
864 $spacer->name = 'spacer';
865 $spacer->main_class = 'pos_options';
866 $admin->addField($spacer, 'start','');
867
868 $i = 0;
869 foreach($static_options as $option => $label)
870 {
871 $posopt = new maxField('radio');
872 $posopt->id = 'position_x_' . $option;
873 $posopt->name = 'position_x';
874 $posopt->title = $label;
875 $posopt->value = $option;
876 $posopt->image = $icon_url . $staticIcons[$option];
877 //default
878 $posopt->checked = checked ( $option, 'auto', false);
879 $posopt->inputclass = 'check_button icon';
880 $end = ($i == count($static_options)-1) ? 'end' : '';
881
882 $admin->addField($posopt, '',$end);
883 $i++;
884 }
885 */
886 $spacer = new maxField('spacer');
887 $spacer->name = 'pos_spacer';
888 $spacer->label = __('Position', 'mbsocial');
889 // $spacer->main_class = 'pos_options';
890 $admin->addField($spacer, 'start','');
891
892 $i = 1;
893 $end = null;
894
895 foreach($staticpos_options as $y_option => $y_label)
896 {
897 foreach($static_options as $x_option => $x_label)
898 {
899 $posopt = new maxField('radio');
900 $posopt->id = 'position_' . $y_option . '_' . $x_option;
901 $posopt->name = 'position';
902 $posopt->title = $y_label . '-' . $x_label;
903 $posopt->value = $y_option . '_' . $x_option;
904 //$posopt->image = $icon_url . 'icon_' . $y_option . $x_option . '.png';
905 $posopt->custom_icon = 'display_icon ' . $y_option . $x_option;
906
907 $posopt->checked = checked ( $option, 'auto', false);
908 $posopt->inputclass = 'check_button icon';
909
910 $start = ( $end == 'end') ? 'start' : ''; // from prev run
911 $end = ($i % 3 === 0 && $i > 0) ? 'end' : '';
912
913 $admin->addField($posopt, $start ,$end);
914 $i++;
915 }
916
917 }
918
919 /* $static= new maxField('option_select');
920 $static->id = 'static';
921 $static->name = $static->id;
922 $static->options = $static_options;
923 $static->label = __('Location on screen', 'mbsocial');
924 $static->note = __('This will define where on the screen your buttons will show up', 'mbsocial');
925
926 $admin->addField($static, 'start', 'end');
927 */
928 /* $static_pos = new maxField('option_select');
929 $static_pos->id = 'staticpos';
930 $static_pos->name = $static_pos->id;
931 $static_pos->options = $staticpos_options;
932 $static_pos->label = __('Position on screen', 'mbsocial');
933 $static_pos->note = __('This will define on what level the buttons will show up' , 'mbsocial');
934
935 $admin->addField($static_pos, 'start', 'end');
936 */
937
938 $fixed = new maxField('switch');
939 $fixed->id = 'fixed_position';
940 $fixed->name = $fixed->id;
941 $fixed->label = __('Position fixed', 'mbsocial');
942 $fixed->value = 1;
943
944 $admin->addField($fixed, 'start', 'end');
945
946 $admin->display_fields();
947
948
949 ?>
950
951
952 </div>
953
954 <div class='share_options'>
955 <?php
956 $share_options = array(
957 'auto' => __('Auto', 'mbsocial'),
958 'current-post' => __('Current Post or Page', 'mbsocial'),
959 'home' => __('Home URL', 'mbsocial'),
960 'custom-url' => __('Custom URL', 'mbsocial'),
961 );
962
963 $share_setting = new maxField('option_select');
964 $share_setting->id = 'share_setting';
965 $share_setting->name = $share_setting->id;
966 $share_setting->label = __('Share URL setting', 'mbsocial');
967 $share_setting->options = $share_options;
968
969 $share_custom = new maxField();
970 $share_custom->id = 'share_custom_url';
971 $share_custom->name = $share_custom->id;
972 $share_custom->label = __('Custom URL','mbsocial');
973 $share_custom->inputclass = 'medium';
974
975 $admin->addField($share_setting, 'start', 'end');
976 $admin->addField($share_custom, 'start', 'end');
977
978 $admin->display_fields();
979 ?>
980
981
982 </div>
983
984
985
986 </div> <!-- content -->
987
988 </div> <!-- wrapper -->
989 <div class='controls'>
990 <button class='button-primary modal_close'>Done</button>
991 </div>
992 </div> <!-- modal -->
993
994
995
996 <?php
997
998 }
999 }
1000