PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / libs / framework / classes / ajax.php
elementskit-lite / libs / framework / classes Last commit date
ajax.php 3 weeks ago install-notice.php 3 weeks ago install-tracker.php 3 weeks ago onboard-status.php 3 weeks ago plugin-data-sender.php 1 year ago plugin-installer.php 3 weeks ago plugin-skin.php 1 year ago plugin-status.php 4 years ago utils.php 1 year ago
ajax.php
154 lines
1 <?php
2
3 namespace ElementsKit_Lite\Libs\Framework\Classes;
4
5 use ElementsKit_Lite\Config\Module_List;
6 use ElementsKit_Lite\Config\Widget_List;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class Ajax {
11 private $utils;
12
13 public function __construct() {
14 add_action( 'wp_ajax_ekit_admin_action', array( $this, 'elementskit_admin_action' ) );
15 add_action( 'wp_ajax_ekit_onboard_plugins', array( $this, 'elementskit_onboard_plugins' ) );
16 $this->utils = Utils::instance();
17 }
18
19 public function elementskit_admin_action() {
20 // Check for nonce security
21 if (!isset($_POST['nonce']) || ! wp_verify_nonce( sanitize_key(wp_unslash($_POST['nonce'])), 'ajax-nonce' ) ) {
22 return;
23 }
24
25 if ( ! current_user_can( 'manage_options' ) ) {
26 return;
27 }
28
29 if ( isset( $_POST['widget_list'] ) ) {
30 $widget_list = Widget_List::instance()->get_list();
31 $widget_list_input = ! is_array( $_POST['widget_list'] ) ? array() : map_deep( wp_unslash( $_POST['widget_list'] ) , 'sanitize_text_field' );
32 $widget_prepared_list = array();
33
34 foreach ( $widget_list as $widget_slug => $widget ) {
35 if ( isset( $widget['package'] ) && $widget['package'] == 'pro-disabled' ) {
36 continue;
37 }
38
39 $widget['status'] = ( in_array( $widget_slug, $widget_list_input ) ? 'active' : 'inactive' );
40
41 $widget_prepared_list[ $widget_slug ] = $widget;
42 }
43
44 // Allow to filter widget status
45 apply_filters( 'elementskit/widgets/status/update', $widget_prepared_list );
46
47 $this->utils->save_option( 'widget_list', $widget_prepared_list );
48 }
49
50 if ( isset( $_POST['module_list'] ) ) {
51 $module_list = Module_List::instance()->get_list( 'optional' );
52 $module_list_input = ! is_array( $_POST['module_list'] ) ? array() : map_deep( wp_unslash( $_POST['module_list'] ) , 'sanitize_text_field' );
53 $module_prepared_list = array();
54
55 foreach ( $module_list as $module_slug => $module ) {
56 if ( isset( $module['package'] ) && $module['package'] == 'pro-disabled' ) {
57 continue;
58 }
59
60 $module['status'] = ( in_array( $module_slug, $module_list_input ) ? 'active' : 'inactive' );
61
62 $module_prepared_list[ $module_slug ] = $module;
63 }
64
65 $this->utils->save_option( 'module_list', $module_prepared_list );
66 }
67
68 if ( isset( $_POST['user_data'] ) ) {
69 $this->utils->save_option( 'user_data', empty( $_POST['user_data'] ) ? array() : map_deep( wp_unslash( $_POST['user_data'] ) , 'wp_filter_nohtml_kses' ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- It will sanitize by wp_filter_nohtml_kses function
70 }
71
72 if ( isset( $_POST['settings'] ) ) {
73 $this->utils->save_settings( empty( $_POST['settings'] ) ? array() : map_deep( wp_unslash( $_POST['settings'] ) , 'sanitize_text_field' ) );
74 }
75
76 do_action( 'elementskit/admin/after_save' );
77
78 $response = array(
79 'message' => self::plugin_activate_message( 'setup_configurations' )
80 );
81
82 $plugins = ! empty( $_POST['our_plugins'] ) && is_array( $_POST['our_plugins'] )
83 ? array_map( 'sanitize_text_field', wp_unslash( $_POST['our_plugins'] ) )
84 : array();
85 if($plugins) {
86 $total_plugins = count($plugins);
87 $total_steps = 1 + $total_plugins;
88 $percentage = ($total_steps > 0) ? (1 / $total_steps) * 100 : 100;
89 $percentage = round($percentage);
90
91 $response['progress'] = $percentage;
92 $response['plugins'] = $plugins;
93 }
94
95 wp_send_json($response);
96
97 wp_die(); // this is required to terminate immediately and return a proper response
98 }
99
100 public function elementskit_onboard_plugins() {
101 // Check for nonce security
102 if (!isset($_POST['nonce']) || ! wp_verify_nonce( sanitize_key(wp_unslash($_POST['nonce'])), 'ajax-nonce' ) ) {
103 return;
104 }
105
106 $plugin_slug = isset( $_POST['plugin_slug'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_slug'] ) ) : '';
107 if ( isset( $plugin_slug ) && current_user_can('install_plugins') ) {
108 $status = \ElementsKit_Lite\Libs\Framework\Classes\Plugin_Installer::single_install_and_activate( $plugin_slug );
109 if ( is_wp_error( $status ) ) {
110 wp_send_json_error( array( 'status' => false ) );
111 } else {
112 wp_send_json_success(
113 array(
114 'message' => self::plugin_activate_message( $plugin_slug )
115 )
116 );
117 }
118 }
119 }
120
121 public static function plugin_activate_message($plugin_slug) {
122 $plugins_message = [
123 'setup_configurations' => esc_html__('Setup Configurations', 'elementskit-lite'),
124 'elementskit-lite/elementskit-lite.php' => esc_html__('Page Builder Elements Activated', 'elementskit-lite'),
125 'getgenie/getgenie.php' => esc_html__('AI Content & SEO Tool Activated', 'elementskit-lite'),
126 'shopengine/shopengine.php' => esc_html__('WooCommerce Builder Activated', 'elementskit-lite'),
127 'metform/metform.php' => esc_html__('Form Builder Activated', 'elementskit-lite'),
128 'emailkit/EmailKit.php' => esc_html__('Email Customizer Activated', 'elementskit-lite'),
129 // 'wp-social/wp-social.php' => esc_html__('Social Integration Activated', 'elementskit-lite'),
130 // 'wp-ultimate-review/wp-ultimate-review.php' => esc_html__('Review Management Activated', 'elementskit-lite'),
131 // 'wp-fundraising-donation/wp-fundraising.php' => esc_html__('Fundraising & Donations', 'elementskit-lite'),
132 'gutenkit-blocks-addon/gutenkit-blocks-addon.php' => esc_html__('Page Builder Blocks Activated', 'elementskit-lite'),
133 'popup-builder-block/popup-builder-block.php' => esc_html__('Popup Builder Activated', 'elementskit-lite'),
134 // 'table-builder-block/table-builder-block.php' => esc_html__('Table Builder Activated', 'elementskit-lite'),
135 // 'rox-dynamic-cpt-fields-engine/rox-dynamic-cpt-fields-engine.php' => esc_html__('Dynamic CPT Fields Activated', 'elementskit-lite'),
136 // 'rox-appointment-booking/rox-appointment-booking.php' => esc_html__('Appointment Booking Activated', 'elementskit-lite'),
137 ];
138
139 if ( array_key_exists( $plugin_slug, $plugins_message ) ) {
140 return esc_html( $plugins_message[$plugin_slug] );
141 } else {
142 return esc_html__( 'Plugin Activated', 'elementskit-lite' );
143 }
144 }
145
146 public function return_json( $data ) {
147 if ( is_array( $data ) || is_object( $data ) ) {
148 return wp_json_encode( $data );
149 } else {
150 return $data;
151 }
152 }
153 }
154