__( 'Invalid request.', 'sellkit' ) ] ); } $post = get_post( $post_id ); if ( ! $post || 'sellkit-funnels' !== $post->post_type ) { wp_send_json_error( [ 'message' => __( 'Invalid funnel.', 'sellkit' ) ] ); } $global_checkout_id = (int) get_option( Checkout::SELLKIT_GLOBAL_CHECKOUT_OPTION, 0 ); if ( $global_checkout_id !== $post_id ) { wp_send_json_error( [ 'message' => __( 'Not the Global Checkout funnel.', 'sellkit' ) ] ); } $updated = wp_update_post( [ 'ID' => $post_id, 'post_status' => $target_status, ], true ); if ( is_wp_error( $updated ) || ! $updated ) { wp_send_json_error( [ 'message' => __( 'Could not update status.', 'sellkit' ) ] ); } $saved_status = get_post_status( $post_id ); wp_send_json_success( $saved_status ? $saved_status : $target_status ); } } new Sellkit_Global_Checkout();