PluginProbe
Social Share Buttons / 1.30
Social Share Buttons v1.30
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.30, at classes/blocks/display_block.php

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