PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/Admin/Ajax/AdminSettings.php +12 -19 2.1.133.2.6 View file →
@@ -2,10 +2,11 @@
2 2
3 3 namespace RadiusTheme\SB\Controllers\Admin\Ajax;
4 4
5 5 use RadiusTheme\SB\Helpers\Fns;
6 +use RadiusTheme\SB\Helpers\Cache;
7 +use RadiusTheme\SB\Models\Settings;
6 8 use RadiusTheme\SB\Models\DataModel;
7 -use RadiusTheme\SB\Models\Settings;
8 9 use RadiusTheme\SB\Traits\SingletonTrait;
9 10
10 11 // Do not allow directly accessing this file.
11 12 if ( ! defined( 'ABSPATH' ) ) {
@@ -24,13 +25,10 @@
24 25 /**
25 26 * Construct function
26 27 */
27 28 private function __construct() {
28 - // add_action( 'wp_ajax_rtsb_settings_fields', [ $this, 'get_settings_fields' ] );
29 - // add_action( 'wp_ajax_rtsb_settings_data', [ $this, 'get_settings_data' ] );
30 29 add_action( 'wp_ajax_rtsb_save_settings_data', [ $this, 'save_settings_data' ] );
31 30 add_action( 'wp_ajax_rtsb_toggle_modules_activation', [ $this, 'toggle_modules' ] );
32 -
33 31 add_action( 'wp_ajax_rtsb_get_multiselect_data', [ $this, 'get_multiselect_data' ] );
34 32 }
35 33
36 34 /**
@@ -42,10 +40,10 @@
42 40 if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) || ! current_user_can( 'manage_options' ) ) {
43 41 wp_send_json_error( esc_html__( 'Security error: Insufficient permissions.', 'shopbuilder' ) );
44 42 }
45 43
46 - $func_with_param = sanitize_text_field( $_REQUEST['func_with_param'] ?? '' );
47 - $s = sanitize_text_field( $_REQUEST['s'] ?? '' );
44 + $func_with_param = sanitize_text_field( $_REQUEST['func_with_param'] ?? '' ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
45 + $s = sanitize_text_field( $_REQUEST['s'] ?? '' ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
48 46 $decodedString = stripslashes( $func_with_param );
49 47 $functionArray = json_decode( $decodedString, true );
50 48 $className = $functionArray[0];
51 49 $methodName = $functionArray[1];
@@ -52,9 +50,9 @@
52 50 $argument = $functionArray[2] ?? [];
53 51 $result = [];
54 52 $params = [];
55 53 if ( class_exists( $className ) && method_exists( $className, $methodName ) ) {
56 - $params[] = $s; // Modify this array with your parameters
54 + $params[] = $s;
57 55 $params[] = $argument;
58 56 $result = call_user_func_array( [ $className, $methodName ], $params );
59 57 }
60 58 wp_send_json_success( $result );
@@ -60,18 +58,8 @@
60 58 wp_send_json_success( $result );
61 59 }
62 60
63 61 /**
64 - * Get settings fields
65 - *
66 - * @return void
67 - */
68 - // public function get_settings_fields() {
69 - // $data = Settings::instance()->get_fields();
70 - // wp_send_json_success( $data );
71 - // }
72 -
73 - /**
74 62 * Get settings Data
75 63 *
76 64 * @return void
77 65 */
@@ -114,8 +102,11 @@
114 102
115 103 if ( boolval( $status['status'] ) ) {
116 104 do_action( 'rtsb/after/saved/settings/success/' . $section_id . '/' . $block_id, $rawOptions );
117 105 do_action( 'rtsb/after/saved/settings/success', $section_id, $block_id, $rawOptions );
106 +
107 + Cache::clear_asset_cache();
108 +
118 109 wp_send_json_success( $status );
119 110 } else {
120 111 wp_send_json_error( $status );
121 112 }
@@ -136,9 +127,9 @@
136 127 );
137 128 }
138 129
139 130 $section_id = isset( $_POST['section_id'] ) ? sanitize_text_field( wp_unslash( $_POST['section_id'] ) ) : '';
140 - $module_ids = isset( $_POST['module_ids'] ) ? array_map( 'sanitize_text_field', $_POST['module_ids'] ) : [];
131 + $module_ids = isset( $_POST['module_ids'] ) ? array_map( 'sanitize_text_field', $_POST['module_ids'] ) : []; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
141 132 $type = isset( $_POST['type'] ) && 'active' === sanitize_text_field( wp_unslash( $_POST['type'] ) ) ? 'active' : false;
142 133
143 134 if ( ! $section_id || empty( $module_ids ) ) {
144 135 wp_send_json_error(
@@ -161,9 +152,9 @@
161 152 if ( isset( $sections[ $section_id ]['list'][ $module_id ] ) ) {
162 153 if ( isset( $sections[ $section_id ]['list'][ $module_id ]['package'] ) && 'pro-disabled' === $sections[ $section_id ]['list'][ $module_id ]['package'] ) {
163 154 continue;
164 155 }
165 - if ( $type === 'active' ) {
156 + if ( 'active' === $type ) {
166 157 $options[ $module_id ]['active'] = 'on';
167 158 $sections[ $section_id ]['list'][ $module_id ]['active'] = 'on';
168 159 } else {
169 160 $options[ $module_id ]['active'] = '';
@@ -169,11 +160,13 @@
169 160 $options[ $module_id ]['active'] = '';
170 161 $sections[ $section_id ]['list'][ $module_id ]['active'] = '';
171 162 }
172 163 }
164 + do_action( 'rtsb/before/save/options', $section_id, $module_id, $options[ $module_id ] ?? [] );
173 165 }
174 166
175 167 DataModel::source()->set_option( $section_id, $options );
168 + Cache::clear_asset_cache();
176 169
177 170 wp_send_json_success(
178 171 [
179 172 'message' => esc_html__( 'Successfully Saved', 'shopbuilder' ),