PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.3.6
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.3.6
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / admin / class-global-checkout.php

class-global-checkout.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 2.3.6, at includes/admin/class-global-checkout.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || die();
4
5 use Sellkit\Global_Checkout\Checkout;
6
7 /**
8 * Sellkit global checkout.
9 *
10 * @since 1.7.4
11 */
12 class Sellkit_Global_Checkout {
13 /**
14 * Class construct.
15 *
16 * @since 1.7.4
17 */
18 public function __construct() {
19 add_action( 'wp_ajax_sellkit_global_checkout_id', [ $this, 'get_global_checkout_funnel_id' ] );
20 add_action( 'wp_ajax_sellkit_global_checkout_toggle_status', [ $this, 'change_status' ] );
21 }
22
23 /**
24 * Get global checkout id.
25 *
26 * @since 1.7.4
27 */
28 public function get_global_checkout_funnel_id() {
29 check_ajax_referer( 'sellkit', 'nonce' );
30
31 $global_checkout_id = get_option( Checkout::SELLKIT_GLOBAL_CHECKOUT_OPTION, 0 );
32
33 // Post not exists.
34 if ( false === get_post_status( $global_checkout_id ) ) {
35 wp_send_json_success( 0 );
36 }
37
38 wp_send_json_success( $global_checkout_id );
39 }
40
41 /**
42 * Toggle global checkout funnel status.
43 *
44 * @since 1.7.4
45 */
46 public function change_status() {
47 check_ajax_referer( 'sellkit', 'nonce' );
48
49 $status = filter_input( INPUT_POST, 'status', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
50 $id = filter_input( INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT );
51 $post = get_post( $id );
52
53 $post->post_status = 'draft';
54
55 if ( 'publish' !== $status ) {
56 $post->post_status = 'publish';
57 }
58
59 $id = wp_update_post( $post );
60
61 wp_send_json_success( $post->post_status );
62 }
63 }
64
65 new Sellkit_Global_Checkout();
66