PluginProbe
Social Share Buttons / 1.19
Social Share Buttons v1.19
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 / general_block.php

general_block.php in Social Share Buttons 1.19, at classes/blocks/general_block.php

156 lines 4.6 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["general"] = array('class' => "generalBlock",
9 'order' => 5);
10
11
12 class generalBlock extends block
13 {
14 protected $blockname = 'general';
15 protected $fields = array(
16 'name' => array('default' => ''),
17 'active' => array('default' => 1),
18 );
19
20 function save_fields($data, $post)
21 {
22 $data = parent::save_fields($data, $post);
23
24 if (! isset($post['active']) && ! is_null($post) && count($post) > 0 )
25 {
26 $data[$this->blockname]['active'] = 0;
27 }
28
29 return $data;
30 }
31
32 public function do_meta_boxes($content, $post)
33 {
34
35 $admin = mbSocial()->admin();
36
37 $metadata = $this->get_block_meta_data($post->ID);
38
39 $is_hidden = isset($metadata['hide']) ? $metadata['hide']: 0;
40
41 $active = new maxField('switch');
42 $active->label = __('Hide', 'mbsocial');
43 $active->id = 'mbsocial_hide';
44 $active->name = $active->id;
45 $active->value = '1';
46 $active->note = __('This option can be used to hide the social share only here', 'mb-social');
47 $active->checked = checked( $is_hidden , 1, false);
48
49 $admin->addField($active, 'start','end');
50
51 $fields = $admin->display_fields(true, true, false);
52
53 $content['display'] = array('title' => __('Display Options', 'mbsocial'),
54 'icon' => 'display',
55 'content' => $fields,
56 );
57
58 return $content;
59 }
60
61 public function save_meta_boxes($metadata, $post_id, $post)
62 {
63 $is_active = isset($post['mbsocial_hide']) ? intval($post['mbsocial_hide']) : 0;
64 $metadata[$this->blockname]['hide'] = $is_active;
65
66 return $metadata;
67
68
69 }
70
71 public function admin()
72 {
73 $admin = MBSocial()->admin();
74
75 ?>
76 <div class='option-container general' id='generalBlock' >
77 <div class='title'><?php _e('General','mbsocial'); ?></div>
78 <div class='inside'>
79 <?php
80
81 $field_name = new maxField() ;
82 $field_name->label = __('Name', 'mbsocial');
83 // $field_name->note = __('Something that you can quickly identify the button with.', 'maxbuttons');
84 $field_name->value = $this->getValue('name');
85 $field_name->id = 'name';
86 $field_name->name = $field_name->id;
87 $field_name->placeholder = __("Name","mbsocial");
88 $field_name->output('start','end');
89
90 // until multi-collection done not in use
91 //$admin->addField($field_name, 'start','end');
92
93 $active = new maxField('switch');
94 $active->label = __('Active', 'mbsocial');
95 $active->id = 'active';
96 $active->name = $active->id;
97 $active->value = '1';
98 $active->checked = checked( $this->getValue('active'), 1, false);
99
100 $admin->addField($active, 'start','end', false);
101
102 $notactive = new maxField('spacer');
103 $notactive->id = 'general_notactive';
104 $notactive->label = __('Warning:', 'mbsocial');
105 $notactive->name = $notactive->id;
106 $notactive->content = '<b class="red">'. __('Social Share is not active. It will not show up anywhere on the frontend!', 'mbsocial') . '</b>';
107 $notactive->conditional = htmlentities(json_encode(array('target' => 'active', 'values' => 'unchecked')));
108
109 $admin->addField($notactive, 'start', 'end', false);
110
111 if ( Install::isPRO() ) {
112 $deskhide = new maxField('spacer');
113 $deskhide->id = 'deskhide';
114 $deskhide->name = $deskhide->id;
115 $deskhide->label = __('Desktop', 'mbsocial');
116 $deskhide->content = 'Shown';
117 $deskhide->conditional = htmlentities(json_encode(array('target' => 'show_desktop', 'values' => 'checked')));
118
119 $deskshow = new maxField('spacer');
120 $deskshow->id = 'deskshow';
121 $deskshow->name = $deskshow->id;
122 $deskshow->label = __('Desktop', 'mbsocial');
123 $deskshow->content = '<b class="red">Hidden</b>';
124 $deskshow->conditional = htmlentities(json_encode(array('target' => 'show_desktop', 'values' => 'unchecked')));
125
126 $admin->addField($deskhide, 'start', '', false );
127 $admin->addField($deskshow, '', 'end', false);
128
129 $mobhide = new maxField('spacer');
130 $mobhide->id = 'mobhide';
131 $mobhide->name = $mobhide->id;
132 $mobhide->label = __('Mobile', 'mbsocial');
133 $mobhide->content = 'Shown';
134 $mobhide->conditional = htmlentities(json_encode(array('target' => 'show_mobile', 'values' => 'checked')));
135
136 $mobshow = new maxField('spacer');
137 $mobshow->id = 'mobshow';
138 $mobshow->name = $mobshow->id;
139 $mobshow->label = __('Mobile', 'mbsocial');
140 $mobshow->content = '<b class="red">Hidden</b>';
141 $mobshow->conditional = htmlentities(json_encode(array('target' => 'show_mobile', 'values' => 'unchecked')));
142
143 $admin->addField($mobhide, 'start', '', false);
144 $admin->addField($mobshow, '', 'end', false);
145 } // IsPro
146
147 $admin->display_fields();
148 ?>
149 </div>
150 </div>
151 <?php
152 }
153
154
155 }
156