PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.2
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 +11 -42 2.1.7 → 2.0.2 View file →
@@ -24,14 +24,15 @@
24 24 /**
25 25 * Construct function
26 26 */
27 27 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' ] );
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 30 add_action( 'wp_ajax_rtsb_save_settings_data', [ $this, 'save_settings_data' ] );
31 31 add_action( 'wp_ajax_rtsb_toggle_modules_activation', [ $this, 'toggle_modules' ] );
32 32
33 33 add_action( 'wp_ajax_rtsb_get_multiselect_data', [ $this, 'get_multiselect_data' ] );
34 +
34 35 }
35 36
36 37 /**
37 38 * Get settings fields
@@ -38,12 +39,8 @@
38 39 *
39 40 * @return void
40 41 */
41 42 public function get_multiselect_data() {
42 - if ( ! Fns::verify_nonce() || ! current_user_can( 'manage_options' ) ) {
43 - wp_send_json_error( esc_html__( 'Security error: Insufficient permissions.', 'shopbuilder' ) );
44 - }
45 -
46 43 $func_with_param = sanitize_text_field( $_REQUEST['func_with_param'] ?? '' );
47 44 $s = sanitize_text_field( $_REQUEST['s'] ?? '' );
48 45 $decodedString = stripslashes( $func_with_param );
49 46 $functionArray = json_decode( $decodedString, true );
@@ -64,12 +61,12 @@
64 61 * Get settings fields
65 62 *
66 63 * @return void
67 64 */
68 -// public function get_settings_fields() {
69 -// $data = Settings::instance()->get_fields();
70 -// wp_send_json_success( $data );
71 -// }
65 + public function get_settings_fields() {
66 + $data = Settings::instance()->get_fields();
67 + wp_send_json_success( $data );
68 + }
72 69
73 70 /**
74 71 * Get settings Data
75 72 *
@@ -88,30 +85,9 @@
88 85 public function save_settings_data() {
89 86 $section_id = isset( $_POST['section_id'] ) ? sanitize_text_field( wp_unslash( $_POST['section_id'] ) ) : '';
90 87 $block_id = isset( $_POST['block_id'] ) ? sanitize_text_field( wp_unslash( $_POST['block_id'] ) ) : '';
91 88 $rawOptions = isset( $_POST['options'] ) ? $_POST['options'] : []; // Fns::set_options Sanitized all array values Before saving.
92 -
93 - if ( ! Fns::verify_nonce() || ! current_user_can( 'manage_options' ) ) {
94 - wp_send_json_error( esc_html__( 'Security error: Insufficient permissions.', 'shopbuilder' ) );
95 - }
96 -
97 - $sections = Settings::instance()->get_sections();
98 - $options = [];
99 - if ( ! empty( $sections[ $section_id ]['list'][ $block_id ]['fields'] ) ) {
100 - $fields = $sections[ $section_id ]['list'][ $block_id ]['fields'];
101 - $db_options = Fns::get_options( $section_id, $block_id );
102 - foreach ( $fields as $field_id => $field ) {
103 - if ( ! array_key_exists( $field_id, $db_options ) ) {
104 - $type = 'array' === gettype( $field['value'] ) ? [] : '';
105 - $options[ $field_id ] = ! empty( $field['value'] ) ? $field['value'] : $type;
106 - }
107 - }
108 - }
109 -
110 - $rawOptions = wp_parse_args( $rawOptions, $options );
111 -
112 - $status = Fns::set_options( $section_id, $block_id, $rawOptions );
113 -
89 + $status = Fns::set_options( $section_id, $block_id, $rawOptions );
114 90 if ( boolval( $status['status'] ) ) {
115 91 do_action( 'rtsb/after/saved/settings/success', $section_id, $block_id, $rawOptions );
116 92 wp_send_json_success( $status );
117 93 } else {
@@ -116,8 +92,9 @@
116 92 wp_send_json_success( $status );
117 93 } else {
118 94 wp_send_json_error( $status );
119 95 }
96 +
120 97 }
121 98
122 99 /**
123 100 * Toggle modules
@@ -124,21 +101,12 @@
124 101 *
125 102 * @return void
126 103 */
127 104 public function toggle_modules() {
128 -
129 105 $section_id = isset( $_POST['section_id'] ) ? sanitize_text_field( wp_unslash( $_POST['section_id'] ) ) : '';
130 106 $module_ids = isset( $_POST['module_ids'] ) ? array_map( 'sanitize_text_field', $_POST['module_ids'] ) : [];
131 107 $type = isset( $_POST['type'] ) && $_POST['type'] === 'active' ? 'active' : false;
132 108
133 - if ( ! Fns::verify_nonce() || ! current_user_can( 'manage_options' ) ) {
134 - wp_send_json_error(
135 - [
136 - 'message' => esc_html__( 'Security error: Insufficient permissions.', 'shopbuilder' ),
137 - ]
138 - );
139 - }
140 -
141 109 if ( ! $section_id || empty( $module_ids ) ) {
142 110 wp_send_json_error(
143 111 [
144 112 'message' => esc_html__( 'Section , block or options may be empty', 'shopbuilder' ),
@@ -144,9 +112,8 @@
144 112 'message' => esc_html__( 'Section , block or options may be empty', 'shopbuilder' ),
145 113 ]
146 114 );
147 115 }
148 -
149 116 $sections = Settings::instance()->get_sections();
150 117 if ( empty( $sections[ $section_id ] ) ) {
151 118 wp_send_json_error(
152 119 [
@@ -178,5 +145,7 @@
178 145 'sections' => $sections,
179 146 ]
180 147 );
181 148 }
149 +
150 +
182 151 }