PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
← All changes | WPDataAccess/API/WPDA_Settings.php +23 -42 5.5.35.5.84 View file →
@@ -62,9 +62,9 @@
62 62 * @return \WP_Error|\WP_REST_Response
63 63 */
64 64 public function save_settings( $request ) {
65 65
66 - if ( ! $this->current_user_can_access( true ) ) {
66 + if ( ! $this->current_user_can_access() ) {
67 67 return $this->unauthorized();
68 68 }
69 69
70 70 if ( ! $this->current_user_token_valid( $request ) ) {
@@ -93,10 +93,9 @@
93 93 return $this->save_column_settings( $dbs, $tbl, $settings );
94 94 case 'rest_api':
95 95 return $this->save_rest_api_settings( $dbs, $tbl, $settings );
96 96 case 'admin_settings':
97 - $theme = $request->get_param( 'theme' );
98 - return $this->save_admin_settings( $dbs, $tbl, $settings, $theme );
97 + return $this->save_admin_settings( $dbs, $tbl, $settings );
99 98 case 'explorer_settings':
100 99 return $this->save_explorer_settings( $dbs, $tbl, $settings );
101 100 }
102 101
@@ -132,12 +131,16 @@
132 131 if ( false === $value || '' === $value ) {
133 132 // Delete column media (no error handling)
134 133 WPDA_Media_Model::delete( $table_name, $column, $schema_name );
135 134 } elseif ( 'string' === gettype( $value) ) {
136 - if ( 1 !== WPDA_Media_Model::update( $table_name, $column, $schema_name ) ) {
135 + if ( false === WPDA_Media_Model::get_column_media( $table_name, $column, $schema_name ) ) {
137 136 if ( ! WPDA_Media_Model::insert( $table_name, $column, $value, 'Yes', $schema_name ) ) {
138 137 $dml_failed++;
139 138 }
139 + } else {
140 + if ( false === WPDA_Media_Model::update( $table_name, $column, $value, $schema_name ) ) {
141 + $dml_failed++;
142 + }
140 143 }
141 144 }
142 145 }
143 146 }
@@ -169,13 +172,15 @@
169 172 return $this->WPDA_Rest_Response( __( 'Changes successfully saved', 'wp-data-access' ) );
170 173 } else {
171 174 if ( '' === $wpdb->last_error ) {
172 175 return new \WP_Error(
176 + /* translators: %s = last dbs error */
173 177 sprintf( __( 'Failed to save changes [%s]', 'wp-data-access' ), $wpdb->last_error ),
174 178 array( 'status' => 420 )
175 179 );
176 180 } else {
177 181 return new \WP_Error(
182 + /* translators: %s = last dbs error */
178 183 sprintf( __( 'Failed to save changes [%s]', 'wp-data-access' ), $wpdb->last_error ),
179 184 array( 'status' => 420 )
180 185 );
181 186 }
@@ -222,8 +227,9 @@
222 227 ) {
223 228 return $this->WPDA_Rest_Response( __( 'Changes successfully saved', 'wp-data-access' ) );
224 229 } else {
225 230 return new \WP_Error(
231 + /* translators: %s = last dbs error */
226 232 sprintf( __( 'Failed to save changes [%s]', 'wp-data-access' ), $wpdb->last_error ),
227 233 array( 'status' => 420 )
228 234 );
229 235 }
@@ -231,8 +237,9 @@
231 237 if ( WPDA_Table_Settings_Model::insert( $table_name, json_encode( $settings ), $schema_name ) ) {
232 238 return $this->WPDA_Rest_Response( __( 'Changes successfully saved', 'wp-data-access' ) );
233 239 } else {
234 240 return new \WP_Error(
241 + /* translators: %s = last dbs error */
235 242 sprintf( __( 'Failed to save changes [%s]', 'wp-data-access' ), $wpdb->last_error ),
236 243 array( 'status' => 420 )
237 244 );
238 245 }
@@ -293,12 +300,15 @@
293 300 $sql_dml = $settings_unused['sql_dml'];
294 301 }
295 302 unset( $settings['unused'] );
296 303 }
304 + WPDA::wpda_log_wp_error($settings);
305 + WPDA::wpda_log_wp_error($settings_unused);
297 306
298 307 if ( null === $sql_dml ) {
299 308 return new \WP_Error(
300 309 sprintf(
310 + /* translators: %s = contact message */
301 311 __( 'Failed to save changes [%s]', 'wp-data-access' ),
302 312 'please contact the plugin development team'
303 313 ),
304 314 array( 'status' => 420 )
@@ -337,8 +347,9 @@
337 347 global $wpdb;
338 348 $msg = '' !== $wpdb->last_error ? " [{$wpdb->last_error}]" : '';
339 349
340 350 return new \WP_Error(
351 + /* translators: %s = error message */
341 352 sprintf( __( 'Failed to save changes [%s]', 'wp-data-access' ), $msg ),
342 353 array( 'status' => 420 )
343 354 );
344 355 }
@@ -424,8 +435,9 @@
424 435 }
425 436
426 437 if ( $dml_succeeded >= 0 && $dml_failed === 0 ) {
427 438 return $this->WPDA_Rest_Response(
439 + /* translators: %s = table name */
428 440 sprintf( __( 'Saved dashboard menus for table `%s`', 'wp-data-access' ), $table_name ),
429 441 $new_menus
430 442 );
431 443 } else {
@@ -432,9 +444,10 @@
432 444 global $wpdb;
433 445 $msg = '' !== $wpdb->last_error ? " [{$wpdb->last_error}]" : '';
434 446
435 447 return new \WP_Error(
436 - sprintf( __( 'Cannot save dashboard menus for table `%s`%s', 'wp-data-access' ), $table_name, $msg ),
448 + /* translators: 1: table name; 2: error message */
449 + sprintf( __( 'Cannot save dashboard menus for table `%1$s`%2$s', 'wp-data-access' ), $table_name, $msg ),
437 450 array( 'status' => 420 )
438 451 );
439 452 }
440 453 }
@@ -485,14 +498,14 @@
485 498 if ( isset( $settings['select'] ) ) {
486 499 unset( $rest_api_settings[ $schema_name ][ $table_name ]['select'] );
487 500 if (
488 501 isset( $rest_api_settings[ $schema_name ][ $table_name ] ) &&
489 - 0 === count( $rest_api_settings[ $schema_name ][ $table_name ] )//phpcs:ignore - 8.1 proof
502 + 0 === count( $rest_api_settings[ $schema_name ][ $table_name ] ) // phpcs:ignore -- 8.1 proof
490 503 ) {
491 504 unset( $rest_api_settings[ $schema_name ][ $table_name ] );
492 505 if (
493 506 isset( $rest_api_settings[ $schema_name ] ) &&
494 - 0 === count( $rest_api_settings[ $schema_name ] )//phpcs:ignore - 8.1 proof
507 + 0 === count( $rest_api_settings[ $schema_name ] ) // phpcs:ignore -- 8.1 proof
495 508 ) {
496 509 unset( $rest_api_settings[ $schema_name ] );
497 510 }
498 511 }
@@ -505,13 +518,14 @@
505 518
506 519 update_option( WPDA_API::WPDA_REST_API_TABLE_ACCESS, $rest_api_settings );
507 520
508 521 return $this->WPDA_Rest_Response(
522 + /* translators: %s = table name */
509 523 sprintf( __( 'Saved REST API settings for table `%s`', 'wp-data-access' ), $table_name )
510 524 );
511 525 }
512 526
513 - private function save_admin_settings( $schema_name, $table_name, $settings, $theme ) {
527 + private function save_admin_settings( $schema_name, $table_name, $settings ) {
514 528 if (
515 529 !
516 530 (
517 531 isset(
@@ -529,10 +543,9 @@
529 543 'user' === $settings['scope']
530 544 ) &&
531 545 (
532 546 'table' === $settings['target'] ||
533 - 'form' === $settings['target'] ||
534 - 'theme' === $settings['target']
547 + 'form' === $settings['target']
535 548 )
536 549
537 550 )
538 551 ) {
@@ -548,17 +561,8 @@
548 561 if ( 'global' === $settings['scope'] ) {
549 562 // Store settings globally.
550 563 if ( null !== $settings['data'] ) {
551 564 update_option( $admin_settings, $settings['data'] );
552 -
553 - if ( null !== $theme ) {
554 - $theme_settings = WPDA_Settings::get_admin_settings_key(
555 - 'theme',
556 - $schema_name ,
557 - $table_name
558 - );
559 - update_option( $theme_settings, $theme );
560 - }
561 565 } else {
562 566 delete_option( $admin_settings );
563 567 }
564 568 } else {
@@ -564,17 +568,8 @@
564 568 } else {
565 569 // Store settings for login user.
566 570 if ( null !== $settings['data'] ) {
567 571 update_user_option( $admin_settings, $settings['data'] );
568 -
569 - if ( null !== $theme ) {
570 - $theme_settings = WPDA_Settings::get_admin_settings_key(
571 - 'theme',
572 - $schema_name ,
573 - $table_name
574 - );
575 - update_user_option( $theme_settings, $theme );
576 - }
577 572 } else {
578 573 delete_user_option( $admin_settings );
579 574 }
580 575 }
@@ -598,15 +593,8 @@
598 593 $schema_name,
599 594 $table_name
600 595 )
601 596 ),
602 - 'theme' => get_option(
603 - WPDA_Settings::get_admin_settings_key(
604 - 'theme',
605 - $schema_name,
606 - $table_name
607 - )
608 - ),
609 597 ),
610 598 'local' => array(
611 599 'table' => get_user_option(
612 600 WPDA_Settings::get_admin_settings_key(
@@ -617,15 +605,8 @@
617 605 ),
618 606 'form' => get_user_option(
619 607 WPDA_Settings::get_admin_settings_key(
620 608 'form',
621 - $schema_name,
622 - $table_name
623 - )
624 - ),
625 - 'theme' => get_user_option(
626 - WPDA_Settings::get_admin_settings_key(
627 - 'theme',
628 609 $schema_name,
629 610 $table_name
630 611 )
631 612 ),