PluginProbe
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.2.2
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.2.2
5.6.11 5.6.10 5.6.9 5.6.8 5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 All 48 releases
← All changes | lib/controllers/settings_controller.php +57 -171 trunk5.2.2 View file →
@@ -15,84 +15,65 @@
15 15
16 16 $this->views_folder = LATEPOINT_VIEWS_ABSPATH . 'settings/';
17 17 $this->vars['page_header'] = OsMenuHelper::get_menu_items_by_id( 'settings' );
18 18 $this->vars['pre_page_header'] = OsMenuHelper::get_label_by_id( 'settings' );
19 - $this->vars['breadcrumbs'][] = array(
20 - 'label' => __( 'Settings', 'latepoint' ),
21 - 'link' => OsRouterHelper::build_link( OsRouterHelper::build_route_name( 'settings', 'general' ) ),
22 - );
19 + $this->vars['breadcrumbs'][] = array( 'label' => __( 'Settings', 'latepoint' ), 'link' => OsRouterHelper::build_link( OsRouterHelper::build_route_name( 'settings', 'general' ) ) );
23 20 }
24 21
25 - public function generate_instant_booking_page_url() {
26 - $url_settings = [];
22 + public function generate_instant_booking_page_url(){
23 + $url_settings = [];
27 24 $instant_booking_settings = $this->params['instant_booking'] ?? [];
28 - if ( ! empty( $instant_booking_settings['selected_agent'] ) ) {
29 - $url_settings['selected_agent'] = $instant_booking_settings['selected_agent'];
30 - }
31 - if ( ! empty( $instant_booking_settings['selected_location'] ) ) {
32 - $url_settings['selected_location'] = $instant_booking_settings['selected_location'];
33 - }
34 - if ( ! empty( $instant_booking_settings['selected_service'] ) ) {
35 - $url_settings['selected_service'] = $instant_booking_settings['selected_service'];
36 - }
37 - if ( ! empty( $instant_booking_settings['background_pattern'] ) ) {
38 - $url_settings['background_pattern'] = $instant_booking_settings['background_pattern'];
39 - }
40 - if ( ! empty( $instant_booking_settings['hide_side_panel'] ) && $instant_booking_settings['hide_side_panel'] == LATEPOINT_VALUE_ON ) {
25 + if(!empty($instant_booking_settings['selected_agent'])) $url_settings['selected_agent'] = $instant_booking_settings['selected_agent'];
26 + if(!empty($instant_booking_settings['selected_location'])) $url_settings['selected_location'] = $instant_booking_settings['selected_location'];
27 + if(!empty($instant_booking_settings['selected_service'])) $url_settings['selected_service'] = $instant_booking_settings['selected_service'];
28 + if(!empty($instant_booking_settings['background_pattern'])) $url_settings['background_pattern'] = $instant_booking_settings['background_pattern'];
29 + if(!empty($instant_booking_settings['hide_side_panel']) && $instant_booking_settings['hide_side_panel'] == LATEPOINT_VALUE_ON){
41 30 $url_settings['hide_side_panel'] = 'yes';
42 31 }
43 - if ( ! empty( $instant_booking_settings['hide_summary'] ) && $instant_booking_settings['hide_summary'] == LATEPOINT_VALUE_ON ) {
32 + if(!empty($instant_booking_settings['hide_summary']) && $instant_booking_settings['hide_summary'] == LATEPOINT_VALUE_ON){
44 33 $url_settings['hide_summary'] = 'yes';
45 34 }
46 35
47 36
48 - $url = OsSettingsHelper::generate_instant_booking_page_url( $url_settings );
37 + $url = OsSettingsHelper::generate_instant_booking_page_url($url_settings);
49 38
50 - $this->send_json(
51 - [
52 - 'status' => LATEPOINT_STATUS_SUCCESS,
53 - 'message' => $url,
54 - ]
55 - );
39 + $this->send_json( [ 'status' => LATEPOINT_STATUS_SUCCESS, 'message' => $url ] );
56 40 }
57 41
58 - public function generate_instant_booking_page() {
59 - $agents = new OsAgentModel();
60 - $this->vars['agents'] = $agents->should_be_active()->get_results_as_models();
61 - $services = new OsServiceModel();
62 - $this->vars['services'] = $services->should_be_active()->get_results_as_models();
63 - $locations = new OsLocationModel();
42 + public function generate_instant_booking_page(){
43 + $agents = new OsAgentModel();
44 + $this->vars['agents'] = $agents->should_be_active()->get_results_as_models();
45 + $services = new OsServiceModel();
46 + $this->vars['services'] = $services->should_be_active()->get_results_as_models();
47 + $locations = new OsLocationModel();
64 48 $this->vars['locations'] = $locations->should_be_active()->get_results_as_models();
65 49
66 50 $url_settings = [];
67 - if ( ! empty( $this->params['agent_id'] ) ) {
68 - $this->vars['selected_agent_id'] = sanitize_text_field( $this->params['agent_id'] );
69 - $url_settings['selected_agent'] = sanitize_text_field( $this->params['agent_id'] );
51 + if(!empty($this->params['agent_id'])){
52 + $this->vars['selected_agent_id'] = sanitize_text_field($this->params['agent_id']);
53 + $url_settings['selected_agent'] = sanitize_text_field($this->params['agent_id']);
70 54 }
71 - if ( ! empty( $this->params['location_id'] ) ) {
72 - $this->vars['selected_location_id'] = sanitize_text_field( $this->params['location_id'] );
73 - $url_settings['selected_location'] = sanitize_text_field( $this->params['location_id'] );
55 + if(!empty($this->params['location_id'])){
56 + $this->vars['selected_location_id'] = sanitize_text_field($this->params['location_id']);
57 + $url_settings['selected_location'] = sanitize_text_field($this->params['location_id']);
74 58 }
75 - if ( ! empty( $this->params['service_id'] ) ) {
76 - $this->vars['selected_service_id'] = sanitize_text_field( $this->params['service_id'] );
77 - $url_settings['selected_service'] = sanitize_text_field( $this->params['service_id'] );
59 + if(!empty($this->params['service_id'])){
60 + $this->vars['selected_service_id'] = sanitize_text_field($this->params['service_id']);
61 + $url_settings['selected_service'] = sanitize_text_field($this->params['service_id']);
78 62 }
79 63
80 - if ( ! empty( $this->params['background_pattern'] ) ) {
81 - $this->vars['background_pattern'] = sanitize_text_field( $this->params['background_pattern'] );
82 - $url_settings['background_pattern'] = sanitize_text_field( $this->params['background_pattern'] );
64 + if(!empty($this->params['background_pattern'])){
65 + $this->vars['background_pattern'] = sanitize_text_field($this->params['background_pattern']);
66 + $url_settings['background_pattern'] = sanitize_text_field($this->params['background_pattern']);
83 67 }
84 68
85 - $this->vars['instant_booking_page_url'] = OsSettingsHelper::generate_instant_booking_page_url( $url_settings );
86 - $this->vars['patterns'] = OsSettingsHelper::instant_page_background_patterns();
69 + $this->vars['instant_booking_page_url'] = OsSettingsHelper::generate_instant_booking_page_url($url_settings);
70 + $this->vars['patterns'] = OsSettingsHelper::instant_page_background_patterns();
87 71
88 72 $this->format_render( __FUNCTION__ );
89 73 }
90 74
91 75 public function export_data() {
92 - // Verify nonce.
93 - $this->check_nonce( 'export_data' );
94 -
95 76 $this->set_layout( 'pure' );
96 77 $this->vars['content'] = OsSettingsHelper::export_data();
97 78 $this->format_render( __FUNCTION__ );
98 79 }
@@ -113,17 +94,12 @@
113 94
114 95 public function start_import() {
115 96 $this->check_nonce( 'import_json_data' );
116 97 if ( $this->params['latepoint_data_erase_acknowledgement'] != 'on' ) {
117 - $this->send_json(
118 - array(
119 - 'status' => LATEPOINT_STATUS_ERROR,
120 - 'message' => __( 'You have to acknowledge the data erase warning', 'latepoint' ),
121 - )
122 - );
98 + $this->send_json( array( 'status' => LATEPOINT_STATUS_ERROR, 'message' => __( 'You have to acknowledge the data erase warning', 'latepoint' ) ) );
123 99 }
124 100
125 - if ( ! empty( $this->files['latepoint_json_data']['tmp_name'][0] ) ) {
101 + if ( !empty( $this->files['latepoint_json_data']['tmp_name'][0] )) {
126 102 WP_Filesystem();
127 103 global $wp_filesystem;
128 104
129 105 $temp_file = $this->files['latepoint_json_data']['tmp_name'][0];
@@ -132,15 +108,15 @@
132 108 if ( $content === false ) {
133 109 $status = LATEPOINT_STATUS_ERROR;
134 110 $message = __( 'Error reading import file', 'latepoint' );
135 111 } else {
136 - try {
112 + try{
137 113 if ( OsSettingsHelper::import_data( $content ) ) {
138 114 $status = LATEPOINT_STATUS_SUCCESS;
139 115 $message = __( 'Data imported', 'latepoint' );
140 116
141 117 }
142 - } catch ( Exception $e ) {
118 + }catch(Exception $e){
143 119 $status = LATEPOINT_STATUS_ERROR;
144 120 $message = $e->getMessage();
145 121 }
146 122 }
@@ -150,14 +126,10 @@
150 126 $message = __( 'You must upload a JSON file to import data from', 'latepoint' );
151 127 }
152 128
153 129
154 - $this->send_json(
155 - array(
156 - 'status' => $status,
157 - 'message' => $message,
158 - )
159 - );
130 + $this->send_json( array( 'status' => $status, 'message' => $message ) );
131 +
160 132 }
161 133
162 134 public function steps_order_modal() {
163 135 $this->vars['steps'] = OsStepsHelper::unflatten_steps( OsStepsHelper::get_step_codes_in_order( true ) );
@@ -165,9 +137,8 @@
165 137 $this->format_render( __FUNCTION__ );
166 138 }
167 139
168 140 public function update_steps_order() {
169 - $this->check_nonce( 'update_steps_order' );
170 141 $new_order = explode( ',', $this->params['steps_order'] );
171 142 $errors = [];
172 143
173 144 if ( $new_order ) {
@@ -185,30 +156,19 @@
185 156 $message = implode( ', ', $errors );
186 157 }
187 158
188 159 if ( $this->get_return_format() == 'json' ) {
189 - $this->send_json(
190 - array(
191 - 'status' => $status,
192 - 'message' => $message,
193 - )
194 - );
160 + $this->send_json( array( 'status' => $status, 'message' => $message ) );
195 161 }
196 162 }
197 163
198 164
199 165 public function set_menu_layout_style() {
200 - $this->check_nonce( 'set_menu_layout_style' );
201 166 $menu_layout_style = ( isset( $this->params['menu_layout_style'] ) && in_array( $this->params['menu_layout_style'], [ 'full', 'compact' ] ) ) ? $this->params['menu_layout_style'] : 'full';
202 167 OsSettingsHelper::set_menu_layout_style( $menu_layout_style );
203 168
204 169 if ( $this->get_return_format() == 'json' ) {
205 - $this->send_json(
206 - array(
207 - 'status' => LATEPOINT_STATUS_SUCCESS,
208 - 'message' => '',
209 - )
210 - );
170 + $this->send_json( array( 'status' => LATEPOINT_STATUS_SUCCESS, 'message' => '' ) );
211 171 }
212 172 }
213 173
214 174 public function notifications() {
@@ -217,12 +177,9 @@
217 177 }
218 178
219 179
220 180 public function pages() {
221 - $this->vars['breadcrumbs'][] = array(
222 - 'label' => __( 'Pages Setup', 'latepoint' ),
223 - 'link' => false,
224 - );
181 + $this->vars['breadcrumbs'][] = array( 'label' => __( 'Pages Setup', 'latepoint' ), 'link' => false );
225 182
226 183 $pages = get_pages();
227 184
228 185 $this->vars['pages'] = $pages;
@@ -230,12 +187,9 @@
230 187 $this->format_render( __FUNCTION__ );
231 188 }
232 189
233 190 public function payments() {
234 - $this->vars['breadcrumbs'][] = array(
235 - 'label' => __( 'Payment Processing', 'latepoint' ),
236 - 'link' => false,
237 - );
191 + $this->vars['breadcrumbs'][] = array( 'label' => __( 'Payment Processing', 'latepoint' ), 'link' => false );
238 192
239 193 $pages = get_pages();
240 194
241 195 $this->vars['pages'] = $pages;
@@ -246,12 +200,9 @@
246 200
247 201
248 202 public function work_periods() {
249 203
250 - $this->vars['breadcrumbs'][] = array(
251 - 'label' => __( 'Work Schedule Settings', 'latepoint' ),
252 - 'link' => false,
253 - );
204 + $this->vars['breadcrumbs'][] = array( 'label' => __( 'Work Schedule Settings', 'latepoint' ), 'link' => false );
254 205
255 206 $this->format_render( __FUNCTION__ );
256 207 }
257 208
@@ -257,12 +208,9 @@
257 208
258 209
259 210 public function general() {
260 211
261 - $this->vars['breadcrumbs'][] = array(
262 - 'label' => __( 'General', 'latepoint' ),
263 - 'link' => false,
264 - );
212 + $this->vars['breadcrumbs'][] = array( 'label' => __( 'General', 'latepoint' ), 'link' => false );
265 213
266 214
267 215 $this->format_render( __FUNCTION__ );
268 216 }
@@ -267,9 +215,8 @@
267 215 $this->format_render( __FUNCTION__ );
268 216 }
269 217
270 218 public function remove_chain_schedule() {
271 - $this->check_nonce( 'remove_chain_schedule' );
272 219 $chain_id = $this->params['chain_id'];
273 220 if ( $chain_id && OsWorkPeriodsHelper::remove_periods_for_chain_id( $chain_id ) ) {
274 221 $response_html = __( 'Date Range Schedule Removed', 'latepoint' );
275 222 $status = LATEPOINT_STATUS_SUCCESS;
@@ -278,19 +225,13 @@
278 225 $status = LATEPOINT_STATUS_ERROR;
279 226 }
280 227
281 228 if ( $this->get_return_format() == 'json' ) {
282 - $this->send_json(
283 - array(
284 - 'status' => $status,
285 - 'message' => $response_html,
286 - )
287 - );
229 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
288 230 }
289 231 }
290 232
291 233 public function remove_custom_day_schedule() {
292 - $this->check_nonce( 'remove_custom_day_schedule' );
293 234 $target_date_string = $this->params['date'];
294 235 $args = [];
295 236 $args['agent_id'] = isset( $this->params['agent_id'] ) ? $this->params['agent_id'] : 0;
296 237 $args['service_id'] = isset( $this->params['service_id'] ) ? $this->params['service_id'] : 0;
@@ -303,22 +244,14 @@
303 244 $status = LATEPOINT_STATUS_ERROR;
304 245 }
305 246
306 247 if ( $this->get_return_format() == 'json' ) {
307 - $this->send_json(
308 - array(
309 - 'status' => $status,
310 - 'message' => $response_html,
311 - )
312 - );
248 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
313 249 }
314 250 }
315 251
316 252
317 253 public function save_columns_for_bookings_table() {
318 - // Verify nonce.
319 - $this->check_nonce( 'bookings_table_columns' );
320 -
321 254 $selected_columns = [];
322 255 if ( isset( $this->params['selected_columns'] ) && $this->params['selected_columns'] ) {
323 256 foreach ( $this->params['selected_columns'] as $column_type => $columns ) {
324 257 foreach ( $columns as $column_key => $selected_column ) {
@@ -328,37 +261,18 @@
328 261 }
329 262 }
330 263 }
331 264 OsSettingsHelper::save_setting_by_name( 'bookings_table_columns', $selected_columns );
332 -
333 - // Save column order if provided.
334 - if ( ! empty( $this->params['columns_order'] ) ) {
335 - $columns_order = array_map( 'sanitize_text_field', explode( ',', $this->params['columns_order'] ) );
336 - $allowed_keys = array_keys( OsSettingsHelper::get_all_bookings_table_columns() );
337 - $columns_order = array_values( array_intersect( $columns_order, $allowed_keys ) );
338 - OsSettingsHelper::save_setting_by_name( 'bookings_table_columns_order', $columns_order );
339 - }
340 -
341 265 if ( $this->get_return_format() == 'json' ) {
342 - $this->send_json(
343 - array(
344 - 'status' => LATEPOINT_STATUS_SUCCESS,
345 - 'message' => __( 'Table Settings Saved', 'latepoint' ),
346 - )
347 - );
266 + $this->send_json( array( 'status' => LATEPOINT_STATUS_SUCCESS, 'message' => __( 'Columns Saved', 'latepoint' ) ) );
348 267 }
349 268 }
350 269
351 - public function premium_modal() {
270 + public function premium_modal(){
352 271
353 272 $this->set_layout( 'none' );
354 273 $response_html = $this->format_render_return( __FUNCTION__ );
355 - $this->send_json(
356 - array(
357 - 'status' => LATEPOINT_STATUS_SUCCESS,
358 - 'message' => $response_html,
359 - )
360 - );
274 + $this->send_json( array( 'status' => LATEPOINT_STATUS_SUCCESS, 'message' => $response_html ) );
361 275 }
362 276
363 277 public function save_custom_day_schedule() {
364 278 $this->check_nonce( 'save_custom_day_schedule' );
@@ -405,14 +319,9 @@
405 319 OsWorkPeriodsHelper::save_work_periods( $work_periods, true );
406 320 }
407 321
408 322 if ( $this->get_return_format() == 'json' ) {
409 - $this->send_json(
410 - array(
411 - 'status' => $status,
412 - 'message' => $response_html,
413 - )
414 - );
323 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
415 324 }
416 325 }
417 326
418 327
@@ -446,14 +355,9 @@
446 355 $response_html = __( 'Work Schedule Updated', 'latepoint' );
447 356 $status = LATEPOINT_STATUS_SUCCESS;
448 357
449 358 if ( $this->get_return_format() == 'json' ) {
450 - $this->send_json(
451 - array(
452 - 'status' => $status,
453 - 'message' => $response_html,
454 - )
455 - );
359 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
456 360 }
457 361 }
458 362
459 363
@@ -497,28 +401,19 @@
497 401 $status = LATEPOINT_STATUS_ERROR;
498 402 }
499 403
500 404 if ( $this->get_return_format() == 'json' ) {
501 - $this->send_json(
502 - array(
503 - 'status' => $status,
504 - 'message' => $response_html,
505 - )
506 - );
405 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
507 406 }
508 407 }
509 408
510 409 public function load_step_settings() {
410 +
511 411 }
512 412
513 413
514 414 public function load_work_period_form() {
515 - $args = [
516 - 'week_day' => 1,
517 - 'agent_id' => 0,
518 - 'service_id' => 0,
519 - 'location_id' => 0,
520 - ];
415 + $args = [ 'week_day' => 1, 'agent_id' => 0, 'service_id' => 0, 'location_id' => 0 ];
521 416
522 417 if ( isset( $this->params['week_day'] ) ) {
523 418 $args['week_day'] = $this->params['week_day'];
524 419 }
@@ -531,25 +426,16 @@
531 426 if ( isset( $this->params['location_id'] ) ) {
532 427 $args['location_id'] = $this->params['location_id'];
533 428 }
534 429
535 - $field_prefix = 'work_periods';
536 - if ( isset( $this->params['field_prefix'] ) ) {
537 - $field_prefix = preg_replace( '/[^a-zA-Z0-9_\[\]]/', '', $this->params['field_prefix'] );
538 - }
539 -
540 - $response_html = OsWorkPeriodsHelper::generate_work_period_form( $args, true, $field_prefix );
430 + $response_html = OsWorkPeriodsHelper::generate_work_period_form( $args );
541 431 $status = LATEPOINT_STATUS_SUCCESS;
542 432
543 433 if ( $this->get_return_format() == 'json' ) {
544 - $this->send_json(
545 - array(
546 - 'status' => $status,
547 - 'message' => $response_html,
548 - )
549 - );
434 + $this->send_json( array( 'status' => $status, 'message' => $response_html ) );
550 435 }
551 436 }
437 +
552 438 }
553 439
554 440
555 -endif;
441 +endif;