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/Backup/WPDA_Data_Export.php +82 -75 5.5.45.5.84 View file →
@@ -1,5 +1,5 @@
1 -<?php // phpcs:ignore Standard.Category.SniffName.ErrorCode
1 +<?php
2 2 /**
3 3 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
4 4 *
5 5 * @package WPDataAccess\Backup
@@ -8,11 +8,10 @@
8 8 namespace WPDataAccess\Backup {
9 9
10 10 use Dropbox\Dropbox;
11 11 use Dropbox\Dropbox\Auth;
12 - use WPDataAccess\Dashboard\WPDA_Dashboard;
13 12 use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists;
14 - use WPDataAccess\Settings\WPDA_Settings_DataBackup;
13 + use WPDataAccess\Settings\WPDA_Settings_Legacy_DataBackup;
15 14 use WPDataAccess\Utilities\WPDA_Export_Sql;
16 15 use WPDataAccess\Utilities\WPDA_Remote_Call;
17 16 use WPDataAccess\WPDA;
18 17 use WPDataAccess\Utilities\WPDA_Message_Box;
@@ -45,9 +44,9 @@
45 44 *
46 45 * Gets and stores the scheduled cron jobs.
47 46 */
48 47 public function __construct() {
49 - $this->schedules = wp_get_schedules();
48 + $this->schedules = wp_get_schedules();
50 49 }
51 50
52 51 /**
53 52 * Data entry form to add or update a data backup
@@ -55,14 +54,14 @@
55 54 * @param string $action Add for new export; Update to edit existing export.
56 55 */
57 56 public function create_export( $action ) {
58 57 $wpda_db_options_activated = get_option( 'wpda_db_options_activated' );
59 - if ( ! is_array( $wpda_db_options_activated ) || 0 === count( $wpda_db_options_activated ) ) {//phpcs:ignore - 8.1 proof
58 + if ( ! is_array( $wpda_db_options_activated ) || 0 === count( $wpda_db_options_activated ) ) { // phpcs:ignore -- 8.1 proof
60 59 echo '<br/>';
61 - echo __( 'You need to define and activate at least one storage device in Data Backup Settings to use this feature.', 'wp-data-access' ); // phpcs:ignore WordPress.Security.EscapeOutput
60 + esc_html_e( 'You need to define and activate at least one storage device in Data Backup Settings to use this feature.', 'wp-data-access' );
62 61 echo '<br/>';
63 62 echo '<a href="?page=wpdataaccess&tab=databackup">&raquo; ';
64 - echo __( 'Define and/or activate a storage device', 'wp-data-access' ); // phpcs:ignore WordPress.Security.EscapeOutput
63 + esc_html_e( 'Define and/or activate a storage device', 'wp-data-access' );
65 64 echo '</a>';
66 65 wp_die();
67 66 }
68 67
@@ -76,17 +75,17 @@
76 75 if ( 'update' === $action ) {
77 76 if ( isset( $_REQUEST['schedule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
78 77 $schedule = sanitize_text_field( wp_unslash( $_REQUEST['schedule'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
79 78 if ( 'wpda_data_backup' !== $schedule ) {
80 - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput
79 + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) );
81 80 }
82 81 } else {
83 - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput
82 + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) );
84 83 }
85 84 if ( isset( $_REQUEST['schedule_args'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
86 85 $backupid = sanitize_text_field( wp_unslash( $_REQUEST['schedule_args'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
87 86 } else {
88 - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput
87 + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) );
89 88 }
90 89 $data_backups = get_option( 'wpda_data_backup_option' );
91 90 $data_backup_found = false;
92 91 foreach ( $data_backups as $data_backup ) {
@@ -97,9 +96,9 @@
97 96 $data_backup_found = true;
98 97 }
99 98 }
100 99 if ( ! $data_backup_found ) {
101 - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput
100 + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) );
102 101 }
103 102 if ( isset( $_REQUEST['interval'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
104 103 $interval = sanitize_text_field( wp_unslash( $_REQUEST['interval'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
105 104 }
@@ -113,9 +112,9 @@
113 112 $table_list = WPDA_Dictionary_Lists::get_tables( false, $schema_name );
114 113 ?>
115 114 <div class="wrap">
116 115 <h1 class="wp-heading-inline">
117 - <?php echo __( 'Data Backup' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
116 + <?php esc_html_e( 'Data Backup', 'wp-data-access' ); ?>
118 117 </h1>
119 118 <div id="wpda_export_import">
120 119 <div class="wpda_export_import">
121 120 <form id="wpda_export_import_form"
@@ -123,11 +122,11 @@
123 122 method="post"
124 123 onsubmit="return pre_submit()">
125 124 <table>
126 125 <tr>
127 - <td style="font-weight:bold;padding-left:10px;"><?php echo __( 'Database Tables' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
126 + <td style="font-weight:bold;padding-left:10px;"><?php esc_html_e( 'Database Tables', 'wp-data-access' ); ?></td>
128 127 <td></td>
129 - <td style="font-weight:bold;padding-left:10px"><?php echo __( 'Tables To Be Exported' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
128 + <td style="font-weight:bold;padding-left:10px"><?php esc_html_e( 'Tables To Be Exported', 'wp-data-access' ); ?></td>
130 129 </tr>
131 130 <tr>
132 131 <td>
133 132 <select id="wpda_table_name_db" name="wpda_table_name_db" multiple size="20"
@@ -154,9 +153,9 @@
154 153 <tr>
155 154 <td colspan="3" style="text-align:center;">
156 155 <table align="center">
157 156 <tr>
158 - <td style="text-align:right;"><?php echo __( 'Backup Id' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
157 + <td style="text-align:right;"><?php esc_html_e( 'Backup Id', 'wp-data-access' ); ?></td>
159 158 <td style="text-align:left;">
160 159 <input
161 160 type="text"
162 161 id="backupid"
@@ -171,13 +170,13 @@
171 170 />
172 171 </td>
173 172 </tr>
174 173 <tr>
175 - <td style="text-align:right;"><?php echo __( 'Backup Interval' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
174 + <td style="text-align:right;"><?php esc_html_e( 'Backup Interval', 'wp-data-access' ); ?></td>
176 175 <td style="text-align:left;">
177 176 <select id="interval" name="interval">
178 177 <?php if ( 'add' === $action ) { ?>
179 - <option value="runonce"><?php echo __( 'Run once (no interval)' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></option>
178 + <option value="runonce"><?php esc_html_e( 'Run once (no interval)', 'wp-data-access' ); ?></option>
180 179 <?php } ?>
181 180 <?php
182 181 foreach ( $this->schedules as $key => $schedule ) {
183 182 echo '<option value="' . esc_attr( $key ) . '">' .
@@ -188,9 +187,9 @@
188 187 </select>
189 188 </td>
190 189 </tr>
191 190 <tr>
192 - <td style="text-align:right;"><?php echo __( 'Backup Location' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
191 + <td style="text-align:right;"><?php esc_html_e( 'Backup Location', 'wp-data-access' ); ?></td>
193 192 <td style="text-align:left;">
194 193 <select id="device" name="device">
195 194 <?php
196 195 foreach ( $wpda_db_options_activated as $key => $value ) {
@@ -212,9 +211,9 @@
212 211 </select>
213 212 </td>
214 213 </tr>
215 214 <tr>
216 - <td style="text-align:right;"><?php echo __( 'Backup Files Kept' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
215 + <td style="text-align:right;"><?php esc_html_e( 'Backup Files Kept', 'wp-data-access' ); ?></td>
217 216 <td style="text-align:left;">
218 217 <select id="keep" name="keep">
219 218 <option value="1">1</option>
220 219 <option value="2">2</option>
@@ -234,14 +233,14 @@
234 233 <td></td>
235 234 <td style="text-align:left;">
236 235 <button type="submit" class="button button-primary">
237 236 <i class="fas fa-check wpda_icon_on_button"></i>
238 - <?php echo __( 'Start' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
237 + <?php esc_html_e( 'Start', 'wp-data-access' ); ?>
239 238 </button>
240 239 <button type="button" class="button button-secondary"
241 240 onclick="window.location.href=window.location.href">
242 241 <i class="fas fa-times-circle wpda_icon_on_button"></i>
243 - <?php echo __( 'Cancel' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
242 + <?php esc_html_e( 'Cancel', 'wp-data-access' ); ?>
244 243 </button>
245 244 </td>
246 245 </tr>
247 246 </table>
@@ -249,8 +248,9 @@
249 248 </tr>
250 249 </table>
251 250 <input type="hidden" name="wpdaschema_name" value="<?php echo esc_attr( $schema_name ); ?>"/>
252 251 <input type="hidden" name="action" value="<?php echo esc_attr( $action ); ?>"/>
252 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( $this->get_wp_nonce() ); ?>"/>
253 253 </form>
254 254 </div>
255 255 </div>
256 256 </div>
@@ -286,13 +286,13 @@
286 286 }
287 287 ?>
288 288 function pre_submit() {
289 289 if (0 === jQuery("#wpda_table_name_export > option").length) {
290 - alert('<?php echo __( 'No tables to be exported' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>');
290 + alert('<?php esc_html_e( 'No tables to be exported', 'wp-data-access' ); ?>');
291 291 return false;
292 292 }
293 293 if ('' === jQuery("#backupid").val().trim()) {
294 - alert('<?php echo __( 'You must specify a backupid' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>');
294 + alert('<?php esc_html_e( 'You must specify a backupid', 'wp-data-access' ); ?>');
295 295 return false;
296 296 }
297 297 jQuery("#wpda_table_name_export > option").each(function () {
298 298 jQuery(this).attr("selected", "true");
@@ -394,9 +394,9 @@
394 394 global $wpdb;
395 395
396 396 echo '<div class="wrap">';
397 397 echo '<h1 class="wp-heading-inline">';
398 - echo __( 'Data Backup' ); // phpcs:ignore WordPress.Security.EscapeOutput
398 + esc_html_e( 'Data Backup', 'wp-data-access' );
399 399 echo '</h1>';
400 400
401 401 if ( $data_backups_found || 'all' === $show_jobs ) {
402 402 echo '<table cellpadding="3" cellspacing="3" border="0" style="border-collapse:collapse;">';
@@ -402,15 +402,15 @@
402 402 echo '<table cellpadding="3" cellspacing="3" border="0" style="border-collapse:collapse;">';
403 403 echo '<tr>';
404 404 echo '<th></th>';
405 405 echo '<th></th>';
406 - echo '<th style="text-align:left;">' . __( 'Hook Name' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
407 - echo '<th style="text-align:left;">' . __( 'Arguments' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
408 - echo '<th style="text-align:left;">' . __( 'Interval' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
409 - echo '<th style="text-align:left;">' . __( 'Next Execution' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
410 - echo '<th style="text-align:left;">' . __( 'Backup Location' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
411 - echo '<th style="text-align:left;">' . __( 'Files Kept' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
412 - echo '<th colspan="2" style="text-align:left;">' . __( 'Status' ) . '</th>'; // phpcs:ignore WordPress.Security.EscapeOutput
406 + echo '<th style="text-align:left;">' . esc_html__( 'Hook Name', 'wp-data-access' ) . '</th>';
407 + echo '<th style="text-align:left;">' . esc_html__( 'Arguments', 'wp-data-access' ) . '</th>';
408 + echo '<th style="text-align:left;">' . esc_html__( 'Interval', 'wp-data-access' ) . '</th>';
409 + echo '<th style="text-align:left;">' . esc_html__( 'Next Execution', 'wp-data-access' ) . '</th>';
410 + echo '<th style="text-align:left;">' . esc_html__( 'Backup Location', 'wp-data-access' ) . '</th>';
411 + echo '<th style="text-align:left;">' . esc_html__( 'Files Kept', 'wp-data-access' ) . '</th>';
412 + echo '<th colspan="2" style="text-align:left;">' . esc_html__( 'Status', 'wp-data-access' ) . '</th>';
413 413 echo '</tr>';
414 414 foreach ( $crons as $key => $cron ) {
415 415 foreach ( $cron as $key => $value ) {
416 416 if ( 'wpda_data_backup' === $key ) {
@@ -444,8 +444,9 @@
444 444 foreach ( $value as $value_key => $value_value ) {
445 445 $schedule_args = isset( $value_value['args'][0] ) ? $value_value['args'][0] : '';
446 446 echo '<input type="hidden" name="schedule_args" value="' . esc_attr( $schedule_args ) . '" />';
447 447 }
448 + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />';
448 449 echo '</form>';
449 450 echo '</td>';
450 451 echo '<td>';
451 452 echo '<form method="post" action="?page=wpda&page_action=wpda_backup">';
@@ -463,8 +464,9 @@
463 464 }
464 465 if ( isset( $data_backups_keep[ $value_value['args'][0] ] ) ) {
465 466 echo '<input type="hidden" name="device" value="' . esc_attr( $data_backups_device[ $value_value['args'][0] ] ) . '" />';
466 467 }
468 + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />';
467 469 echo '</form>';
468 470 echo '</td>';
469 471 } else {
470 472 echo '<td>';
@@ -477,11 +479,11 @@
477 479 echo '</td>';
478 480 foreach ( $value as $value_key => $value_value ) {
479 481 echo '<td>';
480 482 if ( is_array ($value_value['args']) &&
481 - 0 < count( $value_value['args'] ) ) {//phpcs:ignore - 8.1 proof
483 + 0 < count( $value_value['args'] ) ) { // phpcs:ignore -- 8.1 proof
482 484 foreach ( $value_value['args'] as $arg ) {
483 - if ( reset( $value_value['args'] ) !== $arg ) {//phpcs:ignore - 8.1 proof
485 + if ( reset( $value_value['args'] ) !== $arg ) { // phpcs:ignore -- 8.1 proof
484 486 echo ',';
485 487 }
486 488 echo esc_attr( $arg );
487 489 }
@@ -525,9 +527,9 @@
525 527 }
526 528 echo '</td>';
527 529 echo '<td>';
528 530 if ( 'wpda_data_backup' === $key ) {
529 - $resultset = $wpdb->get_results(
531 + $resultset = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
530 532 $wpdb->prepare(
531 533 "
532 534 SELECT `log_time`, `log_type`, `log_msg`
533 535 FROM `{$wpdb->prefix}wpda_logging`
@@ -543,9 +545,9 @@
543 545 echo esc_attr( $resultset[0]['log_type'] ) . ': ' .
544 546 esc_attr( $resultset[0]['log_msg'] ) .
545 547 ' (' . esc_attr( $resultset[0]['log_time'] ) . ')';
546 548 } else {
547 - echo __( 'No logging information found' ); // phpcs:ignore WordPress.Security.EscapeOutput
549 + esc_html_e( 'No logging information found', 'wp-data-access' );
548 550 }
549 551 }
550 552 echo '</td>';
551 553 }
@@ -559,16 +561,17 @@
559 561 ( 1 < $no_data_backup_events ? 's' : '' ) . ' scheduled</strong></td>';
560 562 } else {
561 563 echo '<table>';
562 564 echo '<tr>';
563 - echo '<td><strong>' . __( 'No data backup jobs found' ) . '</strong></td>'; // phpcs:ignore WordPress.Security.EscapeOutput
565 + echo '<td><strong>' . esc_html__( 'No data backup jobs found', 'wp-data-access' ) . '</strong></td>';
564 566 }
565 567 echo '<td>';
566 568 echo '<form method="post" action="?page=wpda&page_action=wpda_backup" style="display: inline-block; vertical-align: unset;">';
567 569 echo '<select name="show_jobs" onchange="jQuery(this).closest(\'form\').submit()" >';
568 - echo '<option value="wpda"' . ( 'all' !== $show_jobs ? 'selected' : '' ) . '>' . __( 'Show plugin jobs only' ) . '</option>'; // phpcs:ignore WordPress.Security.EscapeOutput
569 - echo '<option value="all"' . ( 'all' === $show_jobs ? 'selected' : '' ) . '>' . __( 'Show all WordPress jobs' ) . '</option>'; // phpcs:ignore WordPress.Security.EscapeOutput
570 + echo '<option value="wpda"' . ( 'all' !== $show_jobs ? 'selected' : '' ) . '>' . esc_html__( 'Show plugin jobs only', 'wp-data-access' ) . '</option>';
571 + echo '<option value="all"' . ( 'all' === $show_jobs ? 'selected' : '' ) . '>' . esc_html__( 'Show all WordPress jobs', 'wp-data-access' ) . '</option>';
570 572 echo '</select>';
573 + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />';
571 574 echo '</form>';
572 575 echo '</td>';
573 576 echo '</tr>';
574 577 echo '</table>';
@@ -600,9 +603,9 @@
600 603 // Directly remove data backup to prevent multiple backups.
601 604 $data_backups_new = array();
602 605 foreach ( $data_backups as $data_backup ) {
603 606 if ( $data_backup['id'] !== $backupid ) {
604 - array_push( $data_backups_new, $data_backup );//phpcs:ignore - 8.1 proof
607 + array_push( $data_backups_new, $data_backup ); // phpcs:ignore -- 8.1 proof
605 608 }
606 609 }
607 610 update_option( 'wpda_data_backup_option_runonce', $data_backups_new );
608 611 } else {
@@ -644,9 +647,9 @@
644 647
645 648 if ( 'local_path' === $device ) {
646 649 $local_path = WPDA::get_option( WPDA::OPTION_DB_LOCAL_PATH );
647 650 $client_file_name = $local_path . $filename;
648 - $file = fopen( $client_file_name, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
651 + $file = fopen( $client_file_name, 'w' ); // phpcs:ignore
649 652 $wpda_export = new WPDA_Export_Sql();
650 653 $wpda_export->set_output_stream( $file );
651 654 $wpda_export->export_with_arguments(
652 655 'on',
@@ -655,19 +658,19 @@
655 658 $schema,
656 659 $tables,
657 660 'table'
658 661 );
659 - fclose( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
662 + fclose( $file ); // phpcs:ignore
660 663 $keep_counting = 0;
661 664 $files_sorted = array();
662 665 foreach ( glob( $local_path . "wpda-data-backup-$backupid-*.sql" ) as $filename ) {
663 - array_push( $files_sorted, $filename );//phpcs:ignore - 8.1 proof
666 + array_push( $files_sorted, $filename ); // phpcs:ignore -- 8.1 proof
664 667 }
665 - rsort( $files_sorted );//phpcs:ignore - 8.1 proof
668 + rsort( $files_sorted ); // phpcs:ignore -- 8.1 proof
666 669 foreach ( $files_sorted as $file ) {
667 670 $keep_counting ++;
668 671 if ( $keep_counting > (int) $keep ) {
669 - unlink( $file );
672 + unlink( $file ); // phpcs:ignore
670 673 }
671 674 }
672 675 } elseif ( 'dropbox' === $device ) {
673 676 // To use a stream for Dropbox we first need to write the export to a temporary file.
@@ -682,9 +685,9 @@
682 685 $tables,
683 686 'table'
684 687 );
685 688
686 - $client_access_token = WPDA_Settings_DataBackup::dropbox_get_token();
689 + $client_access_token = WPDA_Settings_Legacy_DataBackup::dropbox_get_token();
687 690 if ( false === $client_access_token ) {
688 691 // Use old token strategy (for older activations).
689 692 $client_access_token = get_option( 'wpda_db_dropbox_access_token' );
690 693 if ( false === $client_access_token ) {
@@ -719,12 +722,12 @@
719 722 }
720 723 $zip->addFile( stream_get_meta_data( $temporary_file )['uri'], $filename );
721 724 $zip->close();
722 725
723 - $zpf = fopen( $zipfile, 'r' );
726 + $zpf = fopen( $zipfile, 'r' ); // phpcs:ignore
724 727 WPDA_Remote_Call::post(
725 728 'https://content.dropboxapi.com/2/files/upload',
726 - fread( $zpf, filesize( $zipfile ) ),
729 + fread( $zpf, filesize( $zipfile ) ), // phpcs:ignore
727 730 false,
728 731 array(
729 732 'Authorization' => "Bearer $client_access_token",
730 733 'Content-Type' => 'application/octet-stream',
@@ -734,9 +737,9 @@
734 737 } else {
735 738 fseek( $temporary_file, 0 );
736 739 WPDA_Remote_Call::post(
737 740 'https://content.dropboxapi.com/2/files/upload',
738 - fread( $temporary_file, filesize( stream_get_meta_data( $temporary_file )['uri'] ) ),
741 + fread( $temporary_file, filesize( stream_get_meta_data( $temporary_file )['uri'] ) ), // phpcs:ignore
739 742 false,
740 743 array(
741 744 'Authorization' => "Bearer $client_access_token",
742 745 'Content-Type' => 'application/octet-stream',
@@ -772,11 +775,11 @@
772 775 if ( isset( $body_content['matches'] ) ) {
773 776 $keep_counting = 0;
774 777 $files_sorted = array();
775 778 foreach ( $body_content['matches'] as $match ) {
776 - array_push( $files_sorted, $match['metadata']['metadata']['name'] );//phpcs:ignore - 8.1 proof
779 + array_push( $files_sorted, $match['metadata']['metadata']['name'] ); // phpcs:ignore -- 8.1 proof
777 780 }
778 - rsort( $files_sorted );//phpcs:ignore - 8.1 proof
781 + rsort( $files_sorted ); // phpcs:ignore -- 8.1 proof
779 782 foreach ( $files_sorted as $file ) {
780 783 $keep_counting++;
781 784 if ( $keep_counting > (int) $keep ) {
782 785 // Remove outdated files.
@@ -814,9 +817,9 @@
814 817 if ( ! isset( $_REQUEST['backupid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
815 818 $this->show_wp_cron();
816 819 $msg = new WPDA_Message_Box(
817 820 array(
818 - 'message_text' => __( 'Mandatory item "backupid" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
821 + 'message_text' => __( 'Mandatory item "backupid" not found', 'wp-data-access' ),
819 822 'message_type' => 'error',
820 823 'message_is_dismissible' => false,
821 824 )
822 825 );
@@ -828,9 +831,9 @@
828 831 if ( ! isset( $_REQUEST['interval'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
829 832 $this->show_wp_cron();
830 833 $msg = new WPDA_Message_Box(
831 834 array(
832 - 'message_text' => __( 'Mandatory item "interval" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
835 + 'message_text' => __( 'Mandatory item "interval" not found', 'wp-data-access' ),
833 836 'message_type' => 'error',
834 837 'message_is_dismissible' => false,
835 838 )
836 839 );
@@ -842,9 +845,9 @@
842 845 if ( ! isset( $_REQUEST['keep'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
843 846 $this->show_wp_cron();
844 847 $msg = new WPDA_Message_Box(
845 848 array(
846 - 'message_text' => __( 'Mandatory item "keep" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
849 + 'message_text' => __( 'Mandatory item "keep" not found', 'wp-data-access' ),
847 850 'message_type' => 'error',
848 851 'message_is_dismissible' => false,
849 852 )
850 853 );
@@ -856,9 +859,9 @@
856 859 if ( ! isset( $_REQUEST['device'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
857 860 $this->show_wp_cron();
858 861 $msg = new WPDA_Message_Box(
859 862 array(
860 - 'message_text' => __( 'Mandatory item "device" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
863 + 'message_text' => __( 'Mandatory item "device" not found', 'wp-data-access' ),
861 864 'message_type' => 'error',
862 865 'message_is_dismissible' => false,
863 866 )
864 867 );
@@ -870,9 +873,9 @@
870 873 if ( ! isset( $_REQUEST['wpda_table_name_export'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
871 874 $this->show_wp_cron();
872 875 $msg = new WPDA_Message_Box(
873 876 array(
874 - 'message_text' => __( 'No tables defined to backup', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
877 + 'message_text' => __( 'No tables defined to backup', 'wp-data-access' ),
875 878 'message_type' => 'error',
876 879 'message_is_dismissible' => false,
877 880 )
878 881 );
@@ -899,13 +902,13 @@
899 902 'keep' => $keep,
900 903 'schema_name' => $schema_name,
901 904 'tables' => $request_tables,
902 905 );
903 - array_push( $data_backups, $data_backup );//phpcs:ignore - 8.1 proof
906 + array_push( $data_backups, $data_backup ); // phpcs:ignore -- 8.1 proof
904 907 if ( ! update_option( 'wpda_data_backup_option_runonce', $data_backups ) ) {
905 908 $msg = new WPDA_Message_Box(
906 909 array(
907 - 'message_text' => __( 'Could not create data backup', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
910 + 'message_text' => __( 'Could not create data backup', 'wp-data-access' ),
908 911 'message_type' => 'error',
909 912 'message_is_dismissible' => false,
910 913 )
911 914 );
@@ -918,9 +921,9 @@
918 921 )
919 922 ) {
920 923 $msg = new WPDA_Message_Box(
921 924 array(
922 - 'message_text' => __( 'Backup failed', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
925 + 'message_text' => __( 'Backup failed', 'wp-data-access' ),
923 926 'message_type' => 'error',
924 927 'message_is_dismissible' => false,
925 928 )
926 929 );
@@ -929,15 +932,15 @@
929 932 }
930 933 ?>
931 934 <div class="wrap">
932 935 <h1 class="wp-heading-inline">
933 - <?php echo __( 'Data Backup' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
936 + <?php esc_html_e( 'Data Backup', 'wp-data-access' ); ?>
934 937 </h1>
935 - <p><?php echo __( 'Data backup started. Please check backup location.' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></p>
938 + <p><?php esc_html_e( 'Data backup started. Please check backup location.', 'wp-data-access' ); ?></p>
936 939 <p>
937 940 <a href="?page=wpda&page_action=wpda_backup" class="button">
938 941 <i class="fas fa-angle-left wpda_icon_on_button"></i>
939 - <?php echo __( 'List' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
942 + <?php esc_html_e( 'List', 'wp-data-access' ); ?>
940 943 </a>
941 944 </p>
942 945 </div>
943 946 <?php
@@ -951,9 +954,9 @@
951 954 if ( $data_backup['id'] === $backupid ) {
952 955 $this->show_wp_cron();
953 956 $msg = new WPDA_Message_Box(
954 957 array(
955 - 'message_text' => __( 'Backup id already exists', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
958 + 'message_text' => __( 'Backup id already exists', 'wp-data-access' ),
956 959 'message_type' => 'error',
957 960 'message_is_dismissible' => false,
958 961 )
959 962 );
@@ -969,14 +972,14 @@
969 972 'keep' => $keep,
970 973 'schema_name' => $schema_name,
971 974 'tables' => $request_tables,
972 975 );
973 - array_push( $data_backups, $data_backup );//phpcs:ignore - 8.1 proof
976 + array_push( $data_backups, $data_backup ); // phpcs:ignore -- 8.1 proof
974 977 if ( ! update_option( 'wpda_data_backup_option', $data_backups ) ) {
975 978 $this->show_wp_cron();
976 979 $msg = new WPDA_Message_Box(
977 980 array(
978 - 'message_text' => __( 'Could not save data backup options', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
981 + 'message_text' => __( 'Could not save data backup options', 'wp-data-access' ),
979 982 'message_type' => 'error',
980 983 'message_is_dismissible' => false,
981 984 )
982 985 );
@@ -1013,9 +1016,9 @@
1013 1016
1014 1017 if ( false === $unschedule ) {
1015 1018 $msg = new WPDA_Message_Box(
1016 1019 array(
1017 - 'message_text' => __( 'Could not delete data backup schedule', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1020 + 'message_text' => __( 'Could not delete data backup schedule', 'wp-data-access' ),
1018 1021 'message_type' => 'error',
1019 1022 'message_is_dismissible' => false,
1020 1023 )
1021 1024 );
@@ -1022,9 +1025,9 @@
1022 1025 $msg->box();
1023 1026 } else {
1024 1027 $msg = new WPDA_Message_Box(
1025 1028 array(
1026 - 'message_text' => __( 'Deleted data backup schedule', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1029 + 'message_text' => __( 'Deleted data backup schedule', 'wp-data-access' ),
1027 1030 )
1028 1031 );
1029 1032 $msg->box();
1030 1033 // Remove job from queue.
@@ -1031,9 +1034,9 @@
1031 1034 $data_backups = get_option( 'wpda_data_backup_option' );
1032 1035 $data_backups_new = array();
1033 1036 foreach ( $data_backups as $data_backup ) {
1034 1037 if ( $data_backup['id'] !== $backupid ) {
1035 - array_push( $data_backups_new, $data_backup );//phpcs:ignore - 8.1 proof
1038 + array_push( $data_backups_new, $data_backup ); // phpcs:ignore -- 8.1 proof
1036 1039 }
1037 1040 }
1038 1041 update_option( 'wpda_data_backup_option', $data_backups_new );
1039 1042 }
@@ -1052,9 +1055,9 @@
1052 1055 $backupid = sanitize_text_field( wp_unslash( $_REQUEST['backupid'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
1053 1056 } else {
1054 1057 $msg = new WPDA_Message_Box(
1055 1058 array(
1056 - 'message_text' => __( 'Mandatory item "backupid" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1059 + 'message_text' => __( 'Mandatory item "backupid" not found', 'wp-data-access' ),
1057 1060 'message_type' => 'error',
1058 1061 'message_is_dismissible' => false,
1059 1062 )
1060 1063 );
@@ -1064,9 +1067,9 @@
1064 1067 $wpda_table_name_export = WPDA::sanitize_text_field_array( $_REQUEST['wpda_table_name_export'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ,WordPress.Security.NonceVerification
1065 1068 } else {
1066 1069 $msg = new WPDA_Message_Box(
1067 1070 array(
1068 - 'message_text' => __( 'No tables defined to backup', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1071 + 'message_text' => __( 'No tables defined to backup', 'wp-data-access' ),
1069 1072 'message_type' => 'error',
1070 1073 'message_is_dismissible' => false,
1071 1074 )
1072 1075 );
@@ -1076,9 +1079,9 @@
1076 1079 $interval = sanitize_text_field( wp_unslash( $_REQUEST['interval'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
1077 1080 } else {
1078 1081 $msg = new WPDA_Message_Box(
1079 1082 array(
1080 - 'message_text' => __( 'Mandatory item "interval" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1083 + 'message_text' => __( 'Mandatory item "interval" not found', 'wp-data-access' ),
1081 1084 'message_type' => 'error',
1082 1085 'message_is_dismissible' => false,
1083 1086 )
1084 1087 );
@@ -1088,9 +1091,9 @@
1088 1091 $keep = sanitize_text_field( wp_unslash( $_REQUEST['keep'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
1089 1092 } else {
1090 1093 $msg = new WPDA_Message_Box(
1091 1094 array(
1092 - 'message_text' => __( 'Mandatory item "keep" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1095 + 'message_text' => __( 'Mandatory item "keep" not found', 'wp-data-access' ),
1093 1096 'message_type' => 'error',
1094 1097 'message_is_dismissible' => false,
1095 1098 )
1096 1099 );
@@ -1100,9 +1103,9 @@
1100 1103 $device = sanitize_text_field( wp_unslash( $_REQUEST['device'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
1101 1104 } else {
1102 1105 $msg = new WPDA_Message_Box(
1103 1106 array(
1104 - 'message_text' => __( 'Mandatory item "device" not found', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1107 + 'message_text' => __( 'Mandatory item "device" not found', 'wp-data-access' ),
1105 1108 'message_type' => 'error',
1106 1109 'message_is_dismissible' => false,
1107 1110 )
1108 1111 );
@@ -1117,9 +1120,9 @@
1117 1120 $timestamp = wp_next_scheduled( 'wpda_data_backup', array( $backupid ) );
1118 1121 if ( false === wp_unschedule_event( $timestamp, 'wpda_data_backup', array( $backupid ) ) ) {
1119 1122 $msg = new WPDA_Message_Box(
1120 1123 array(
1121 - 'message_text' => __( 'Could not delete data backup schedule', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput
1124 + 'message_text' => __( 'Could not delete data backup schedule', 'wp-data-access' ),
1122 1125 'message_type' => 'error',
1123 1126 'message_is_dismissible' => false,
1124 1127 )
1125 1128 );
@@ -1129,9 +1132,9 @@
1129 1132 $data_backups = get_option( 'wpda_data_backup_option' );
1130 1133 $data_backups_new = array();
1131 1134 foreach ( $data_backups as $data_backup ) {
1132 1135 if ( $data_backup['id'] !== $backupid ) {
1133 - array_push( $data_backups_new, $data_backup );//phpcs:ignore - 8.1 proof
1136 + array_push( $data_backups_new, $data_backup ); // phpcs:ignore -- 8.1 proof
1134 1137 } else {
1135 1138 $data_backup_updated = array(
1136 1139 'id' => $backupid,
1137 1140 'keep' => $keep,
@@ -1138,9 +1141,9 @@
1138 1141 'device' => $device,
1139 1142 'schema_name' => $schema_name,
1140 1143 'tables' => $wpda_table_name_export,
1141 1144 );
1142 - array_push( $data_backups_new, $data_backup_updated );//phpcs:ignore - 8.1 proof
1145 + array_push( $data_backups_new, $data_backup_updated ); // phpcs:ignore -- 8.1 proof
1143 1146 }
1144 1147 }
1145 1148 update_option( 'wpda_data_backup_option', $data_backups_new );
1146 1149 // Reschedule job with new arguments.
@@ -1146,8 +1149,12 @@
1146 1149 // Reschedule job with new arguments.
1147 1150 wp_schedule_event( current_time( 'timestamp' ), $interval, 'wpda_data_backup', array( $backupid ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
1148 1151 }
1149 1152 $this->show_wp_cron();
1153 + }
1154 +
1155 + private function get_wp_nonce() {
1156 + return wp_create_nonce( 'wpda-backup-' . WPDA::get_current_user_login() );
1150 1157 }
1151 1158
1152 1159 }
1153 1160