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-collections.php +34 -106 trunk1.1.2 View file →
@@ -137,26 +137,8 @@
137 137 else
138 138 return false; // no binds, don't check.
139 139 }
140 140
141 - // When MB PRO is configured to output CSS via file.
142 - static function outputFileCSS()
143 - {
144 - $collection_id = intval($_GET['id']);
145 - $doc_id = intval($_GET['doc']);
146 - $collection = new collection($collection_id);
147 - $css = $collection->getDisplayCSS($doc_id);
148 - header( "Content-type: text/css; charset: UTF-8" );
149 -
150 - if ($css)
151 - {
152 - header( "Content-type: text/css; charset: UTF-8" );
153 - echo $css;
154 - }
155 - exit();
156 -
157 - }
158 -
159 141 /* Try to find the current place we are at in the site ( front / blog / page etc ) .*/
160 142 protected static function getCurrentHook()
161 143 {
162 144 $hook = '';
@@ -177,25 +159,24 @@
177 159 {
178 160 $hook = "display_archive";
179 161 }
180 162
181 - $post_types = \get_post_types(
182 - array('public' => true,
183 - '_builtin' => false,
184 - )
185 - );
163 + $post_types = \get_post_types(
164 + array('public' => true,
165 + '_builtin' => false,
166 + )
167 + );
186 168
187 - $this_post_type = get_post_type( get_the_ID() );
169 + $this_post_type = get_post_type( get_the_ID() );
188 170
189 - foreach($post_types as $post_type) // custom post type
171 + foreach($post_types as $post_type) // custom post type
172 + {
173 + if ($post_type == $this_post_type)
190 174 {
191 - if ($post_type == $this_post_type)
192 - {
193 - $hook = 'display_' . $this_post_type;
194 - }
195 -
175 + $hook = 'display_' . $this_post_type;
196 176 }
197 177
178 + }
198 179
199 180 return $hook;
200 181 }
201 182
@@ -284,26 +265,11 @@
284 265 parse_str($form, $post_form);
285 266
286 267 $collection_id = intval($post_form["collection_id"]);
287 268
288 - $admin = MB()->getClass('admin');
289 - $collection = new collection();
269 + $admin = MB()->getClass('admin');
290 270
291 271
292 - if (! Install::isPro() && $collection_id == 0)
293 - {
294 - $collections = self::getCollections();
295 - if (count($collections) > 0)
296 - {
297 - $result = array(
298 - "error" => true,
299 - );
300 - $collection->endAjaxRequest($result);
301 - }
302 - }
303 -
304 -
305 -
306 272 $close_text = __('Close', 'maxbuttons');
307 273
308 274 $result = array(
309 275 "error" => false,
@@ -314,10 +280,15 @@
314 280 "new_nonce" => 0,
315 281 "title" => __("Saved!","mbsocial"),
316 282 );
317 283
284 +
285 +
286 +
287 + $collection = new collection();
318 288 $collection->set($collection_id);
319 289
290 +
320 291 // this can be a new id (!)
321 292 $collection_id = $collection->save($post_form);
322 293
323 294 $result["data"]["id"] = $collection_id;
@@ -326,40 +297,17 @@
326 297 // $result["data"]["reload"] = apply_filters("collections_ajax_force_reload",$force_reload);
327 298
328 299 // $result["title"] = $result_title["success"];
329 300
330 - $collection->endAjaxRequest($result);
301 + $admin->endAjaxRequest($result);
302 +
303 + //echo json_encode($result);
304 + //exit();
331 305 }
332 306
333 - static function ajax_remove_collection()
334 - {
335 - $admin = MB()->getClass('admin');
336 -
337 - $collection_id = intval($_POST['param']);
338 - $collection = new collection();
339 -
340 -
341 - $url = admin_url('?page=maxbuttons-social');
342 -
343 - $result = array(
344 - 'error' => false,
345 - 'redirect' => $url,
346 - );
347 -
348 - global $wpdb;
349 -
350 - $table = maxUtils::get_collection_table_name();
351 - $where = array("collection_id" => $collection_id);
352 - $where_format = array("%d");
353 - $wpdb->delete($table, $where, $where_format);
354 -
355 -
356 - $collection->endAjaxRequest($result);
357 -
358 - }
359 -
360 307 static function ajax_action_front()
361 308 {
309 +
362 310 // only for trivial front page actions!
363 311 self::ajax_action(array("ajax_nopriv" => true));
364 312 }
365 313
@@ -368,8 +316,9 @@
368 316 ob_start();
369 317 $defaults = array("ajax_nopriv" => false);
370 318 $args = wp_parse_args($args, $defaults);
371 319
320 +
372 321 $admin = MB()->getClass('admin');
373 322
374 323 $nonce = isset($_POST["nonce"]) ? $_POST["nonce"] : false;
375 324 $block_name = sanitize_text_field($_POST["block_name"]);
@@ -376,31 +325,14 @@
376 325 $block_action = sanitize_text_field($_POST["block_action"]);
377 326 $block_data = (isset($_POST["block_data"])) ? $_POST["block_data"] : '';
378 327 $action = sanitize_text_field($_POST["action"]);
379 328
380 - // Weirdly only one, but security, lets checks this without changing other code too much
381 - $possible_actions =['mbsocial_get_count'];
382 -
383 329 $collection_id = intval($_POST["collection_id"]);
384 - $collection = new collection($collection_id);
330 + // $collection_type = sanitize_text_field($_POST["collection_type"]);
385 331
386 - if (false === in_array($action, $possible_actions))
332 + if(! $args["ajax_nopriv"])
387 333 {
388 - $result["error"] = true;
389 - $result["body"] = __("Bad Action","maxbuttons");
390 - $result["result"] = false;
391 - $result["title"] = __("Security error","maxbuttons");
392 - $result["data"] = array("id" => $collection_id);
393 -
394 - $collection->endAjaxRequest($result);
395 - }
396 -
397 -
398 - // $collection_type = sanitize_text_field($_POST["collection_type"]);
399 -
400 - //if(! $args["ajax_nopriv"])
401 - //{
402 - if (! wp_verify_nonce($nonce, "maxsocial_ajax_action-" . $collection_id))
334 + if (! wp_verify_nonce($nonce, $action . "-" . $collection_id))
403 335 {
404 336 $result["error"] = true;
405 337 $result["body"] = __("Nonce not verified","maxbuttons");
406 338 $result["result"] = false;
@@ -406,12 +338,12 @@
406 338 $result["result"] = false;
407 339 $result["title"] = __("Security error","maxbuttons");
408 340 $result["data"] = array("id" => $collection_id);
409 341
410 - $collection->endAjaxRequest($result);
342 + $admin->endAjaxRequest($result);
411 343
412 344 }
413 - //}
345 + }
414 346
415 347 $result = array(
416 348 "error" => false,
417 349 "body" => '',
@@ -419,13 +351,16 @@
419 351 "data" => array(),
420 352 "new_nonce" => 0,
421 353 );
422 354
355 + $collection = new collection($collection_id);
356 +
423 357 $result = $collection->doBlockAjax($result, $block_name, $block_action, $block_data);
424 358
425 359 //ob_end_clean(); // prevent PHP errors from breaking JSON response.
426 360
427 - $collection->endAjaxRequest($result);
361 + $admin->endAjaxRequest($result);
362 + $results = $collection->get_meta($name, 'collection_name');
428 363 }
429 364
430 365
431 366 public static function ajax_refreshblock()
@@ -585,16 +520,9 @@
585 520 }
586 521
587 522 $collection->saveData();
588 523
589 - $collection_id = $collection->getID();
590 - $url = admin_url('?page=maxbuttons-social');
591 - $url = add_query_arg('social_id', $collection_id, $url);
592 -
593 - echo json_encode( array(
594 - 'done' => true,
595 - 'redirect' => $url,
596 - ) );
524 + echo json_encode( array('done' => true) );
597 525 exit();
598 526
599 527 }
600 528
@@ -605,9 +533,9 @@
605 533 global $wpdb;
606 534
607 535 $table = maxUtils::get_collection_table_name();
608 536
609 - $sql = "SELECT distinct collection_id from $table WHERE collection_key = 'collection_type' and collection_value = 'social_share' order by collection_id ";
537 + $sql = "SELECT distinct collection_id from $table WHERE collection_key = 'collection_type' and collection_value = 'social_share' ";
610 538
611 539 $results = $wpdb->get_col($sql);
612 540 return $results;
613 541 }