| @@ -10,8 +10,9 @@ | ||
| 10 | 10 | * List Table component class. |
| 11 | 11 | * |
| 12 | 12 | * @since 1.1.0 |
| 13 | 13 | * @SuppressWarnings(PHPMD.UnusedPrivateMethod) |
| 14 | + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) | |
| 14 | 15 | */ |
| 15 | 16 | class Sellkit_Admin_List_Table { |
| 16 | 17 | |
| 17 | 18 | /** |
| @@ -131,9 +132,9 @@ | ||
| 131 | 132 | // Sanitize. |
| 132 | 133 | $post = filter_input( INPUT_POST, 'post', FILTER_DEFAULT, FILTER_FORCE_ARRAY ); |
| 133 | 134 | $sub_action = sellkit_htmlspecialchars( INPUT_POST, 'sub_action' ); |
| 134 | 135 | |
| 135 | - if ( count( $post ) < 3 ) { | |
| 136 | + if ( is_array( $post ) && count( $post ) < 3 ) { | |
| 136 | 137 | $post = (array) get_post( $post['ID'] ); |
| 137 | 138 | } |
| 138 | 139 | |
| 139 | 140 | call_user_func( [ $this, "handle_post_{$sub_action}" ], $post ); |
| @@ -417,9 +418,15 @@ | ||
| 417 | 418 | if ( empty( $posts ) ) { |
| 418 | 419 | wp_send_json_error(); |
| 419 | 420 | } |
| 420 | 421 | |
| 422 | + $global_checkout_id = intval( get_option( Checkout::SELLKIT_GLOBAL_CHECKOUT_OPTION, 0 ) ); | |
| 423 | + | |
| 421 | 424 | foreach ( $posts as $post ) { |
| 425 | + if ( $post->ID === $global_checkout_id ) { | |
| 426 | + continue; | |
| 427 | + } | |
| 428 | + | |
| 422 | 429 | $post = (array) $post; |
| 423 | 430 | |
| 424 | 431 | $data['data'][] = $this->export_single_funnel( $post ); |
| 425 | 432 | } |
| @@ -436,8 +443,12 @@ | ||
| 436 | 443 | $json = filter_input( INPUT_POST, 'funnel', FILTER_DEFAULT ); |
| 437 | 444 | $page = filter_input( INPUT_POST, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 438 | 445 | $data = json_decode( $json ); |
| 439 | 446 | |
| 447 | + if ( 'multi' === $data->type && 'checkout' === $page ) { | |
| 448 | + wp_send_json_error( esc_html__( 'You can not import multiple funnels to the global checkout.', 'sellkit' ) ); | |
| 449 | + } | |
| 450 | + | |
| 440 | 451 | $ajax_handler = new Ajax_Handler(); |
| 441 | 452 | |
| 442 | 453 | if ( 'single' === $data->type ) { |
| 443 | 454 | $funnel_data = $data->data->funnel; |
| @@ -455,8 +466,10 @@ | ||
| 455 | 466 | |
| 456 | 467 | if ( 'checkout' === $page && (int) $funnel_id > 0 ) { |
| 457 | 468 | update_option( Checkout::SELLKIT_GLOBAL_CHECKOUT_OPTION, $funnel_id ); |
| 458 | 469 | } |
| 470 | + | |
| 471 | + wp_send_json_success(); | |
| 459 | 472 | } |
| 460 | 473 | } |
| 461 | 474 | |
| 462 | 475 | Sellkit_Admin_List_Table::get_instance(); |