| @@ -159,25 +159,24 @@ | ||
| 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 | |
| 171 | + foreach($post_types as $post_type) // custom post type | |
| 172 | + { | |
| 173 | + if ($post_type == $this_post_type) | |
| 172 | 174 | { |
| 173 | - if ($post_type == $this_post_type) | |
| 174 | - { | |
| 175 | - $hook = 'display_' . $this_post_type; | |
| 176 | - } | |
| 177 | - | |
| 175 | + $hook = 'display_' . $this_post_type; | |
| 178 | 176 | } |
| 179 | 177 | |
| 178 | + } | |
| 180 | 179 | |
| 181 | 180 | return $hook; |
| 182 | 181 | } |
| 183 | 182 | |
| @@ -266,25 +265,11 @@ | ||
| 266 | 265 | parse_str($form, $post_form); |
| 267 | 266 | |
| 268 | 267 | $collection_id = intval($post_form["collection_id"]); |
| 269 | 268 | |
| 270 | - $admin = MB()->getClass('admin'); | |
| 269 | + $admin = MB()->getClass('admin'); | |
| 271 | 270 | |
| 272 | 271 | |
| 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 | - | |
| 287 | 272 | $close_text = __('Close', 'maxbuttons'); |
| 288 | 273 | |
| 289 | 274 | $result = array( |
| 290 | 275 | "error" => false, |
| @@ -295,11 +280,15 @@ | ||
| 295 | 280 | "new_nonce" => 0, |
| 296 | 281 | "title" => __("Saved!","mbsocial"), |
| 297 | 282 | ); |
| 298 | 283 | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 299 | 287 | $collection = new collection(); |
| 300 | 288 | $collection->set($collection_id); |
| 301 | 289 | |
| 290 | + | |
| 302 | 291 | // this can be a new id (!) |
| 303 | 292 | $collection_id = $collection->save($post_form); |
| 304 | 293 | |
| 305 | 294 | $result["data"]["id"] = $collection_id; |
| @@ -309,35 +298,13 @@ | ||
| 309 | 298 | |
| 310 | 299 | // $result["title"] = $result_title["success"]; |
| 311 | 300 | |
| 312 | 301 | $admin->endAjaxRequest($result); |
| 302 | + | |
| 303 | + //echo json_encode($result); | |
| 304 | + //exit(); | |
| 313 | 305 | } |
| 314 | 306 | |
| 315 | - static function ajax_remove_collection() | |
| 316 | - { | |
| 317 | - $admin = MB()->getClass('admin'); | |
| 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 | - | |
| 340 | 307 | static function ajax_action_front() |
| 341 | 308 | { |
| 342 | 309 | |
| 343 | 310 | // only for trivial front page actions! |
| @@ -553,16 +520,9 @@ | ||
| 553 | 520 | } |
| 554 | 521 | |
| 555 | 522 | $collection->saveData(); |
| 556 | 523 | |
| 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 | - ) ); | |
| 524 | + echo json_encode( array('done' => true) ); | |
| 565 | 525 | exit(); |
| 566 | 526 | |
| 567 | 527 | } |
| 568 | 528 | |
| @@ -573,9 +533,9 @@ | ||
| 573 | 533 | global $wpdb; |
| 574 | 534 | |
| 575 | 535 | $table = maxUtils::get_collection_table_name(); |
| 576 | 536 | |
| 577 | - $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' "; | |
| 578 | 538 | |
| 579 | 539 | $results = $wpdb->get_col($sql); |
| 580 | 540 | return $results; |
| 581 | 541 | } |