PluginProbe
Social Share Buttons / 1.1.2
Social Share Buttons v1.1.2
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
← All changes | classes/class-admin.php +11 -183 1.71.1.2 View file →
@@ -56,8 +56,9 @@
56 56 {
57 57 $fields = apply_filters('mbsocial/display_fields', $this->fields);
58 58 $output = '';
59 59
60 +
60 61 foreach($fields as $id => $item)
61 62 {
62 63 $field = $item['field'];
63 64 $output .= $field->output($item['start'], $item['end']);
@@ -100,8 +101,9 @@
100 101 {
101 102 $active_networks = array();
102 103 }
103 104 $networks = mbSocial()->networks()->get();
105 +
104 106 $selected = array();
105 107 $unselected = array();
106 108 $readmore = array();
107 109
@@ -108,19 +110,14 @@
108 110 // set active networks. Support doubles.
109 111 foreach($active_networks as $index => $network_name)
110 112 {
111 113 $network = mbSocial()->networks()->get($network_name);
112 - if (! is_object($network)) // could be removed network.
113 - continue;
114 - if ($network->get('is_active'))
115 - $selected[$index] = $network;
114 + $selected[$index] = $network;
116 115 }
117 116
118 117 foreach($networks as $index => $network)
119 118 {
120 119 $priority = $network->get('priority');
121 - if (! $network->get('is_active'))
122 - { continue; }
123 120 $is_active = array_search($network->get('network'), $active_networks); // retrieve the array index
124 121
125 122 if ($is_active !== false)
126 123 {
@@ -126,16 +123,22 @@
126 123 {
127 124 $priority = 'selected';
128 125 }
129 126
127 + /* if ($priority == 'selected')
128 + {
129 + continue; // ignore active, since it's set earlier.
130 + //$selected[$is_active] = $network;
131 +
132 + } */
130 133 if ($priority == 'unselected')
131 134 $unselected[] = $network;
132 135 if ($priority == 'readmore')
133 136 $readmore[] = $network;
134 137
138 +
135 139 if ($network->get('network') == 'maxbutton' && $priority != 'readmore') // exceptions
136 140 {
137 -
138 141 $readmore[] = $network;
139 142 }
140 143
141 144
@@ -140,8 +143,9 @@
140 143
141 144
142 145 } // foreach networks
143 146
147 +
144 148 // Sort networks by order saved.
145 149 ksort($selected);
146 150 return array('selected' => $selected, 'unselected' => $unselected, 'readmore' => $readmore);
147 151 }
@@ -154,105 +158,8 @@
154 158 $networks_array = $this->get_default_networks($active_networks);
155 159 return $networks_array;
156 160 }
157 161
158 - // render icons with input from different icon libraries (/future)
159 - public function renderIcon($args)
160 - {
161 - $defaults = array('icon' => '',
162 - 'icon_type' => '',
163 - 'icon_size' => 20,
164 - 'title' => '',
165 - );
166 -
167 - $args = wp_parse_args($args, $defaults);
168 -
169 - $icon_type = $args['icon_type'];
170 - $icon = $args['icon'];
171 - $icon_size = $args['icon_size'];
172 - $title = $args['title'];
173 -
174 - $faUtils = FAUtils::getInstance();
175 -
176 - switch($icon_type)
177 - {
178 - case 'fa': // FA5
179 - case 'fab':
180 - case 'fas':
181 - case 'far':
182 - $args = array('icon' => trim($icon_type) . ' ' . trim($icon), 'title' => $title);
183 - if ($icon_size)
184 - {
185 - $args['size'] = $icon_size;
186 - }
187 -
188 - $svg = $faUtils->getFASVG($args);
189 - $output = "<span class='mb-icon'>$svg</span>";
190 - break;
191 - case 'nucleo':
192 - $output = "<span class='mb-icon'><i class='$icon_type $icon' title='$title' > </i></span>";
193 - break;
194 - case 'svg':
195 - case 'png': // via network settings, or whatever.
196 - $output = "<span class='mb-icon " . $icon_type . "'><img src='" . $icon . "' alt='" . $title . "'></span>";
197 - break;
198 - case 'image': // via media uploader
199 - case 'image-remote':
200 - if ($icon_type == 'image-remote') // when loading a custom network, before import
201 - {
202 - $url = $args['image_url'];
203 - $output = '<img src="' . $url . '" border="0" />';
204 - }
205 - else {
206 - $image_id = isset($args['image_id']) ? $args['image_id'] : false;
207 - $image_size = isset($args['image_size']) ? $args['image_size'] : false;
208 -
209 - $img_data = wp_get_attachment_image_src($image_id, $image_size);
210 -
211 - $width = $img_data[1];
212 - $height = $img_data[2];
213 - $url = $img_data[0];
214 - $output = '<span class="mb-icon ' . $icon_type . '"><img src="' . $url . '" width="' . $width . '" height="' . $height . '" border="0" /></span>';
215 - }
216 - break;
217 - default:
218 - $output = '';
219 - break;
220 - }
221 -
222 - return apply_filters('display/render/icon', $output, $args);
223 - }
224 -
225 - public function applyVars($string)
226 - {
227 - //$vars = $this->getShareData();
228 - $w = MBSocial()->whistle();
229 -
230 - preg_match_all('/\{(.*?)\}/im', $string, $matches);
231 - //$vars = (isset($vars[0]) && count($vars[0]) > 0) ? $vars[0] : array();
232 -
233 - if (count($matches) == 0)
234 - return $string;
235 -
236 - $vars = $matches[0]; // i.e. {url}
237 - $clean_vars = $matches[1]; // i.e. url
238 -
239 - for($i = 0; $i < count($vars); $i++)
240 - {
241 - $var = $vars[$i];
242 - $clean_var = $clean_vars[$i];
243 -
244 - if (strpos($string, $var) !== false)
245 - {
246 - $val = $w->ask('display/vars/' . $clean_var);
247 - $string = str_replace($var, $val, $string);
248 - }
249 -
250 - }
251 -
252 - return $string;
253 - }
254 -
255 162 public function header( $args = array() )
256 163 {
257 164 $defaults = array(
258 165 'title' => '',
@@ -275,85 +182,6 @@
275 182 <a href="https://maxbuttons.com" target="_blank">', '</a>') );
276 183 }
277 184
278 185
279 - public function do_review_notice () {
280 -
281 - $current_user_id = get_current_user_id();
282 - $version = MBSOCIAL_VERSION_NUM;
283 -
284 - $review = get_user_meta( $current_user_id, 'mbsocial_review_notice' , true );
285 -
286 - if ($review == '')
287 - {
288 - //$created = get_option("MBFREE_CREATED");
289 - $show = time() + (7* DAY_IN_SECONDS);
290 - update_user_meta($current_user_id, 'mbsocial_review_notice', $show);
291 - return;
292 - }
293 -
294 - $display_review = false;
295 -
296 - if ($review == 'off')
297 - { return; // no show
298 -
299 - }
300 - elseif (is_numeric($review))
301 - {
302 - $now = time();
303 -
304 - if ($now > $review)
305 - {
306 - $display_review = true;
307 -
308 - }
309 - }
310 -
311 - // load style / script. It's seperated since it should show everywhere in admin.
312 - if ($display_review)
313 - {
314 - add_action( 'admin_notices', array( $this, 'mbsocial_review_notice'));
315 - // registered in admin scripts
316 - if (method_exists(MB(), 'load_library'))
317 - MB()->load_library('review_notice');
318 - }
319 -
320 - }
321 -
322 - public function mbsocial_review_notice()
323 - {
324 - include_once( mbSocial()->get_plugin_path() . '/admin/review_notice.php');
325 - }
326 -
327 - public function save_review_notice()
328 - {
329 - $status = isset($_POST["status"]) ? sanitize_text_field($_POST["status"]) : '';
330 - $current_user_id = get_current_user_id();
331 -
332 - $updated = false;
333 -
334 - if ($status == 'off')
335 - {
336 - $updated = true;
337 - update_user_meta($current_user_id, 'mbsocial_review_notice', 'off');
338 -
339 - }
340 - if ($status == 'later')
341 - {
342 - $updated = true;
343 - $later = time() + (14 * DAY_IN_SECONDS );
344 -
345 - update_user_meta($current_user_id, 'mbsocial_review_notice', $later);
346 - }
347 - if ($status == 'reviewoffer-dismiss') // different ad!
348 - {
349 - $updated = true;
350 - update_user_meta($current_user_id, 'mbsocial_review_notice', 'off');
351 -
352 - }
353 -
354 - echo json_encode(array("updated" => $updated)) ;
355 -
356 - exit();
357 - }
358 186
359 187 }