PluginProbe
Social Share Buttons / 0.9
Social Share Buttons v0.9
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 0.9, at classes/blocks/display_block.php

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