| @@ -159,25 +159,26 @@ | ||
| 159 | 159 | { |
| 160 | 160 | $hook = "display_archive"; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $post_types = \get_post_types( | |
| 164 | - array('public' => true, | |
| 165 | - '_builtin' => false, | |
| 166 | - ) | |
| 167 | - ); | |
| 163 | + $post_types = \get_post_types( | |
| 164 | + array('public' => true, | |
| 165 | + '_builtin' => false, | |
| 166 | + ) | |
| 167 | + ); | |
| 168 | 168 | |
| 169 | - $this_post_type = get_post_type( get_the_ID() ); | |
| 169 | + $this_post_type = get_post_type( get_the_ID() ); | |
| 170 | 170 | |
| 171 | - foreach($post_types as $post_type) // custom post type | |
| 172 | - { | |
| 173 | - if ($post_type == $this_post_type) | |
| 171 | + foreach($post_types as $post_type) // custom post type | |
| 174 | 172 | { |
| 175 | - $hook = 'display_' . $this_post_type; | |
| 173 | + if ($post_type == $this_post_type) | |
| 174 | + { | |
| 175 | + $hook = 'display_' . $this_post_type; | |
| 176 | + } | |
| 177 | + | |
| 176 | 178 | } |
| 179 | + | |
| 177 | 180 | |
| 178 | - } | |
| 179 | - | |
| 180 | 181 | return $hook; |
| 181 | 182 | } |
| 182 | 183 | |
| 183 | 184 | static function doContentHooks($content) |
| @@ -265,11 +266,25 @@ | ||
| 265 | 266 | parse_str($form, $post_form); |
| 266 | 267 | |
| 267 | 268 | $collection_id = intval($post_form["collection_id"]); |
| 268 | 269 | |
| 269 | - $admin = MB()->getClass('admin'); | |
| 270 | + $admin = MB()->getClass('admin'); | |
| 270 | 271 | |
| 271 | 272 | |
| 273 | + if (! Install::isPro() && $collection_id == 0) | |
| 274 | + { | |
| 275 | + $collections = self::getCollections(); | |
| 276 | + if (count($collections) > 0) | |
| 277 | + { | |
| 278 | + $result = array( | |
| 279 | + "error" => true, | |
| 280 | + ); | |
| 281 | + $admin->endAjaxRequest($result); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 272 | 287 | $close_text = __('Close', 'maxbuttons'); |
| 273 | 288 | |
| 274 | 289 | $result = array( |
| 275 | 290 | "error" => false, |
| @@ -280,15 +295,11 @@ | ||
| 280 | 295 | "new_nonce" => 0, |
| 281 | 296 | "title" => __("Saved!","mbsocial"), |
| 282 | 297 | ); |
| 283 | 298 | |
| 284 | - | |
| 285 | - | |
| 286 | - | |
| 287 | 299 | $collection = new collection(); |
| 288 | 300 | $collection->set($collection_id); |
| 289 | 301 | |
| 290 | - | |
| 291 | 302 | // this can be a new id (!) |
| 292 | 303 | $collection_id = $collection->save($post_form); |
| 293 | 304 | |
| 294 | 305 | $result["data"]["id"] = $collection_id; |
| @@ -298,13 +309,35 @@ | ||
| 298 | 309 | |
| 299 | 310 | // $result["title"] = $result_title["success"]; |
| 300 | 311 | |
| 301 | 312 | $admin->endAjaxRequest($result); |
| 313 | + } | |
| 302 | 314 | |
| 303 | - //echo json_encode($result); | |
| 304 | - //exit(); | |
| 305 | - } | |
| 315 | + static function ajax_remove_collection() | |
| 316 | + { | |
| 317 | + $admin = MB()->getClass('admin'); | |
| 306 | 318 | |
| 319 | + $collection_id = intval($_POST['param']); | |
| 320 | + | |
| 321 | + $url = admin_url('?page=maxbuttons-social'); | |
| 322 | + | |
| 323 | + $result = array( | |
| 324 | + 'error' => false, | |
| 325 | + 'redirect' => $url, | |
| 326 | + ); | |
| 327 | + | |
| 328 | + global $wpdb; | |
| 329 | + | |
| 330 | + $table = maxUtils::get_collection_table_name(); | |
| 331 | + $where = array("collection_id" => $collection_id); | |
| 332 | + $where_format = array("%d"); | |
| 333 | + $wpdb->delete($table, $where, $where_format); | |
| 334 | + | |
| 335 | + | |
| 336 | + $admin->endAjaxRequest($result); | |
| 337 | + | |
| 338 | + } | |
| 339 | + | |
| 307 | 340 | static function ajax_action_front() |
| 308 | 341 | { |
| 309 | 342 | |
| 310 | 343 | // only for trivial front page actions! |
| @@ -520,9 +553,16 @@ | ||
| 520 | 553 | } |
| 521 | 554 | |
| 522 | 555 | $collection->saveData(); |
| 523 | 556 | |
| 524 | - echo json_encode( array('done' => true) ); | |
| 557 | + $collection_id = $collection->getID(); | |
| 558 | + $url = admin_url('?page=maxbuttons-social'); | |
| 559 | + $url = add_query_arg('social_id', $collection_id, $url); | |
| 560 | + | |
| 561 | + echo json_encode( array( | |
| 562 | + 'done' => true, | |
| 563 | + 'redirect' => $url, | |
| 564 | + ) ); | |
| 525 | 565 | exit(); |
| 526 | 566 | |
| 527 | 567 | } |
| 528 | 568 | |
| @@ -533,9 +573,9 @@ | ||
| 533 | 573 | global $wpdb; |
| 534 | 574 | |
| 535 | 575 | $table = maxUtils::get_collection_table_name(); |
| 536 | 576 | |
| 537 | - $sql = "SELECT distinct collection_id from $table WHERE collection_key = 'collection_type' and collection_value = 'social_share' "; | |
| 577 | + $sql = "SELECT distinct collection_id from $table WHERE collection_key = 'collection_type' and collection_value = 'social_share' order by collection_id "; | |
| 538 | 578 | |
| 539 | 579 | $results = $wpdb->get_col($sql); |
| 540 | 580 | return $results; |
| 541 | 581 | } |