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

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