PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.2.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.2.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / admin-legacy-core / ajax / learn.php

learn.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.2.0, at admin-legacy-core/ajax/learn.php

83 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CartFlows Learn ajax actions.
4 *
5 * @package CartFlows
6 */
7
8 namespace CartflowsAdmin\AdminLegacyCore\Ajax;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 use CartflowsAdmin\AdminLegacyCore\Ajax\AjaxBase;
16
17 /**
18 * Class Learn.
19 */
20 class Learn extends AjaxBase {
21
22 /**
23 * Instance
24 *
25 * @access private
26 * @var object Class object.
27 * @since 1.0.0
28 */
29 private static $instance;
30
31 /**
32 * Initiator
33 *
34 * @since 1.0.0
35 * @return object initialized object of class.
36 */
37 public static function get_instance() {
38 if ( ! isset( self::$instance ) ) {
39 self::$instance = new self();
40 }
41 return self::$instance;
42 }
43
44 /**
45 * Register_ajax_events.
46 *
47 * @return void
48 */
49 public function register_ajax_events() {
50
51 if ( current_user_can( 'cartflows_manage_settings' ) ) {
52
53 $ajax_events = array(
54 'save_learn_completed',
55 );
56 $this->init_ajax_events( $ajax_events );
57 }
58 }
59
60 /**
61 * AJAX handler – persist completed module IDs to option.
62 *
63 * @return void
64 */
65 public function save_learn_completed() {
66 check_ajax_referer( 'cartflows_save_learn_completed', 'nonce' );
67
68 $module_ids = isset( $_POST['module_ids'] )
69 ? json_decode( sanitize_text_field( wp_unslash( $_POST['module_ids'] ) ), true )
70 : array();
71
72 if ( ! is_array( $module_ids ) || empty( $module_ids ) ) {
73 wp_send_json_error();
74 }
75
76 $module_ids = array_map( 'sanitize_text_field', $module_ids );
77
78 update_option( 'wcf_learn_data', $module_ids );
79
80 wp_send_json_success();
81 }
82 }
83