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 +13 -19 2.1.83.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 */
@@ -112,9 +100,13 @@
112 100
113 101 $status = Fns::set_options( $section_id, $block_id, $rawOptions );
114 102
115 103 if ( boolval( $status['status'] ) ) {
104 + do_action( 'rtsb/after/saved/settings/success/' . $section_id . '/' . $block_id, $rawOptions );
116 105 do_action( 'rtsb/after/saved/settings/success', $section_id, $block_id, $rawOptions );
106 +
107 + Cache::clear_asset_cache();
108 +
117 109 wp_send_json_success( $status );
118 110 } else {
119 111 wp_send_json_error( $status );
120 112 }
@@ -135,9 +127,9 @@
135 127 );
136 128 }
137 129
138 130 $section_id = isset( $_POST['section_id'] ) ? sanitize_text_field( wp_unslash( $_POST['section_id'] ) ) : '';
139 - $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
140 132 $type = isset( $_POST['type'] ) && 'active' === sanitize_text_field( wp_unslash( $_POST['type'] ) ) ? 'active' : false;
141 133
142 134 if ( ! $section_id || empty( $module_ids ) ) {
143 135 wp_send_json_error(
@@ -160,9 +152,9 @@
160 152 if ( isset( $sections[ $section_id ]['list'][ $module_id ] ) ) {
161 153 if ( isset( $sections[ $section_id ]['list'][ $module_id ]['package'] ) && 'pro-disabled' === $sections[ $section_id ]['list'][ $module_id ]['package'] ) {
162 154 continue;
163 155 }
164 - if ( $type === 'active' ) {
156 + if ( 'active' === $type ) {
165 157 $options[ $module_id ]['active'] = 'on';
166 158 $sections[ $section_id ]['list'][ $module_id ]['active'] = 'on';
167 159 } else {
168 160 $options[ $module_id ]['active'] = '';
@@ -168,11 +160,13 @@
168 160 $options[ $module_id ]['active'] = '';
169 161 $sections[ $section_id ]['list'][ $module_id ]['active'] = '';
170 162 }
171 163 }
164 + do_action( 'rtsb/before/save/options', $section_id, $module_id, $options[ $module_id ] ?? [] );
172 165 }
173 166
174 167 DataModel::source()->set_option( $section_id, $options );
168 + Cache::clear_asset_cache();
175 169
176 170 wp_send_json_success(
177 171 [
178 172 'message' => esc_html__( 'Successfully Saved', 'shopbuilder' ),