| @@ -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 |
| @@ -54,14 +54,14 @@ | ||
| 54 | 54 | * @param string $action Add for new export; Update to edit existing export. |
| 55 | 55 | */ |
| 56 | 56 | public function create_export( $action ) { |
| 57 | 57 | $wpda_db_options_activated = get_option( 'wpda_db_options_activated' ); |
| 58 | - 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 | |
| 59 | 59 | echo '<br/>'; |
| 60 | - 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' ); | |
| 61 | 61 | echo '<br/>'; |
| 62 | 62 | echo '<a href="?page=wpdataaccess&tab=databackup">» '; |
| 63 | - 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' ); | |
| 64 | 64 | echo '</a>'; |
| 65 | 65 | wp_die(); |
| 66 | 66 | } |
| 67 | 67 | |
| @@ -75,17 +75,17 @@ | ||
| 75 | 75 | if ( 'update' === $action ) { |
| 76 | 76 | if ( isset( $_REQUEST['schedule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 77 | 77 | $schedule = sanitize_text_field( wp_unslash( $_REQUEST['schedule'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 78 | 78 | if ( 'wpda_data_backup' !== $schedule ) { |
| 79 | - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 79 | + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) ); | |
| 80 | 80 | } |
| 81 | 81 | } else { |
| 82 | - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 82 | + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) ); | |
| 83 | 83 | } |
| 84 | 84 | if ( isset( $_REQUEST['schedule_args'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 85 | 85 | $backupid = sanitize_text_field( wp_unslash( $_REQUEST['schedule_args'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 86 | 86 | } else { |
| 87 | - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 87 | + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) ); | |
| 88 | 88 | } |
| 89 | 89 | $data_backups = get_option( 'wpda_data_backup_option' ); |
| 90 | 90 | $data_backup_found = false; |
| 91 | 91 | foreach ( $data_backups as $data_backup ) { |
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | $data_backup_found = true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | if ( ! $data_backup_found ) { |
| 100 | - wp_die( __( 'ERROR: Wrong arguments', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 100 | + wp_die( esc_attr__( 'ERROR: Wrong arguments', 'wp-data-access' ) ); | |
| 101 | 101 | } |
| 102 | 102 | if ( isset( $_REQUEST['interval'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 103 | 103 | $interval = sanitize_text_field( wp_unslash( $_REQUEST['interval'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 104 | 104 | } |
| @@ -112,9 +112,9 @@ | ||
| 112 | 112 | $table_list = WPDA_Dictionary_Lists::get_tables( false, $schema_name ); |
| 113 | 113 | ?> |
| 114 | 114 | <div class="wrap"> |
| 115 | 115 | <h1 class="wp-heading-inline"> |
| 116 | - <?php echo __( 'Data Backup' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 116 | + <?php esc_html_e( 'Data Backup', 'wp-data-access' ); ?> | |
| 117 | 117 | </h1> |
| 118 | 118 | <div id="wpda_export_import"> |
| 119 | 119 | <div class="wpda_export_import"> |
| 120 | 120 | <form id="wpda_export_import_form" |
| @@ -122,11 +122,11 @@ | ||
| 122 | 122 | method="post" |
| 123 | 123 | onsubmit="return pre_submit()"> |
| 124 | 124 | <table> |
| 125 | 125 | <tr> |
| 126 | - <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> | |
| 127 | 127 | <td></td> |
| 128 | - <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> | |
| 129 | 129 | </tr> |
| 130 | 130 | <tr> |
| 131 | 131 | <td> |
| 132 | 132 | <select id="wpda_table_name_db" name="wpda_table_name_db" multiple size="20" |
| @@ -153,9 +153,9 @@ | ||
| 153 | 153 | <tr> |
| 154 | 154 | <td colspan="3" style="text-align:center;"> |
| 155 | 155 | <table align="center"> |
| 156 | 156 | <tr> |
| 157 | - <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> | |
| 158 | 158 | <td style="text-align:left;"> |
| 159 | 159 | <input |
| 160 | 160 | type="text" |
| 161 | 161 | id="backupid" |
| @@ -170,13 +170,13 @@ | ||
| 170 | 170 | /> |
| 171 | 171 | </td> |
| 172 | 172 | </tr> |
| 173 | 173 | <tr> |
| 174 | - <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> | |
| 175 | 175 | <td style="text-align:left;"> |
| 176 | 176 | <select id="interval" name="interval"> |
| 177 | 177 | <?php if ( 'add' === $action ) { ?> |
| 178 | - <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> | |
| 179 | 179 | <?php } ?> |
| 180 | 180 | <?php |
| 181 | 181 | foreach ( $this->schedules as $key => $schedule ) { |
| 182 | 182 | echo '<option value="' . esc_attr( $key ) . '">' . |
| @@ -187,9 +187,9 @@ | ||
| 187 | 187 | </select> |
| 188 | 188 | </td> |
| 189 | 189 | </tr> |
| 190 | 190 | <tr> |
| 191 | - <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> | |
| 192 | 192 | <td style="text-align:left;"> |
| 193 | 193 | <select id="device" name="device"> |
| 194 | 194 | <?php |
| 195 | 195 | foreach ( $wpda_db_options_activated as $key => $value ) { |
| @@ -211,9 +211,9 @@ | ||
| 211 | 211 | </select> |
| 212 | 212 | </td> |
| 213 | 213 | </tr> |
| 214 | 214 | <tr> |
| 215 | - <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> | |
| 216 | 216 | <td style="text-align:left;"> |
| 217 | 217 | <select id="keep" name="keep"> |
| 218 | 218 | <option value="1">1</option> |
| 219 | 219 | <option value="2">2</option> |
| @@ -233,14 +233,14 @@ | ||
| 233 | 233 | <td></td> |
| 234 | 234 | <td style="text-align:left;"> |
| 235 | 235 | <button type="submit" class="button button-primary"> |
| 236 | 236 | <i class="fas fa-check wpda_icon_on_button"></i> |
| 237 | - <?php echo __( 'Start' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 237 | + <?php esc_html_e( 'Start', 'wp-data-access' ); ?> | |
| 238 | 238 | </button> |
| 239 | 239 | <button type="button" class="button button-secondary" |
| 240 | 240 | onclick="window.location.href=window.location.href"> |
| 241 | 241 | <i class="fas fa-times-circle wpda_icon_on_button"></i> |
| 242 | - <?php echo __( 'Cancel' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 242 | + <?php esc_html_e( 'Cancel', 'wp-data-access' ); ?> | |
| 243 | 243 | </button> |
| 244 | 244 | </td> |
| 245 | 245 | </tr> |
| 246 | 246 | </table> |
| @@ -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,9 +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="' . $this->get_wp_nonce() . '" />'; | |
| 448 | + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />'; | |
| 449 | 449 | echo '</form>'; |
| 450 | 450 | echo '</td>'; |
| 451 | 451 | echo '<td>'; |
| 452 | 452 | echo '<form method="post" action="?page=wpda&page_action=wpda_backup">'; |
| @@ -464,9 +464,9 @@ | ||
| 464 | 464 | } |
| 465 | 465 | if ( isset( $data_backups_keep[ $value_value['args'][0] ] ) ) { |
| 466 | 466 | echo '<input type="hidden" name="device" value="' . esc_attr( $data_backups_device[ $value_value['args'][0] ] ) . '" />'; |
| 467 | 467 | } |
| 468 | - echo '<input type="hidden" name="wp_nonce" value="' . $this->get_wp_nonce() . '" />'; | |
| 468 | + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />'; | |
| 469 | 469 | echo '</form>'; |
| 470 | 470 | echo '</td>'; |
| 471 | 471 | } else { |
| 472 | 472 | echo '<td>'; |
| @@ -479,11 +479,11 @@ | ||
| 479 | 479 | echo '</td>'; |
| 480 | 480 | foreach ( $value as $value_key => $value_value ) { |
| 481 | 481 | echo '<td>'; |
| 482 | 482 | if ( is_array ($value_value['args']) && |
| 483 | - 0 < count( $value_value['args'] ) ) {//phpcs:ignore - 8.1 proof | |
| 483 | + 0 < count( $value_value['args'] ) ) { // phpcs:ignore -- 8.1 proof | |
| 484 | 484 | foreach ( $value_value['args'] as $arg ) { |
| 485 | - if ( reset( $value_value['args'] ) !== $arg ) {//phpcs:ignore - 8.1 proof | |
| 485 | + if ( reset( $value_value['args'] ) !== $arg ) { // phpcs:ignore -- 8.1 proof | |
| 486 | 486 | echo ','; |
| 487 | 487 | } |
| 488 | 488 | echo esc_attr( $arg ); |
| 489 | 489 | } |
| @@ -527,9 +527,9 @@ | ||
| 527 | 527 | } |
| 528 | 528 | echo '</td>'; |
| 529 | 529 | echo '<td>'; |
| 530 | 530 | if ( 'wpda_data_backup' === $key ) { |
| 531 | - $resultset = $wpdb->get_results( | |
| 531 | + $resultset = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 532 | 532 | $wpdb->prepare( |
| 533 | 533 | " |
| 534 | 534 | SELECT `log_time`, `log_type`, `log_msg` |
| 535 | 535 | FROM `{$wpdb->prefix}wpda_logging` |
| @@ -545,9 +545,9 @@ | ||
| 545 | 545 | echo esc_attr( $resultset[0]['log_type'] ) . ': ' . |
| 546 | 546 | esc_attr( $resultset[0]['log_msg'] ) . |
| 547 | 547 | ' (' . esc_attr( $resultset[0]['log_time'] ) . ')'; |
| 548 | 548 | } else { |
| 549 | - echo __( 'No logging information found' ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 549 | + esc_html_e( 'No logging information found', 'wp-data-access' ); | |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | echo '</td>'; |
| 553 | 553 | } |
| @@ -561,17 +561,17 @@ | ||
| 561 | 561 | ( 1 < $no_data_backup_events ? 's' : '' ) . ' scheduled</strong></td>'; |
| 562 | 562 | } else { |
| 563 | 563 | echo '<table>'; |
| 564 | 564 | echo '<tr>'; |
| 565 | - 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>'; | |
| 566 | 566 | } |
| 567 | 567 | echo '<td>'; |
| 568 | 568 | echo '<form method="post" action="?page=wpda&page_action=wpda_backup" style="display: inline-block; vertical-align: unset;">'; |
| 569 | 569 | echo '<select name="show_jobs" onchange="jQuery(this).closest(\'form\').submit()" >'; |
| 570 | - echo '<option value="wpda"' . ( 'all' !== $show_jobs ? 'selected' : '' ) . '>' . __( 'Show plugin jobs only' ) . '</option>'; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 571 | - 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>'; | |
| 572 | 572 | echo '</select>'; |
| 573 | - echo '<input type="hidden" name="wp_nonce" value="' . $this->get_wp_nonce() . '" />'; | |
| 573 | + echo '<input type="hidden" name="wp_nonce" value="' . esc_attr( $this->get_wp_nonce() ) . '" />'; | |
| 574 | 574 | echo '</form>'; |
| 575 | 575 | echo '</td>'; |
| 576 | 576 | echo '</tr>'; |
| 577 | 577 | echo '</table>'; |
| @@ -603,9 +603,9 @@ | ||
| 603 | 603 | // Directly remove data backup to prevent multiple backups. |
| 604 | 604 | $data_backups_new = array(); |
| 605 | 605 | foreach ( $data_backups as $data_backup ) { |
| 606 | 606 | if ( $data_backup['id'] !== $backupid ) { |
| 607 | - 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 | |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | update_option( 'wpda_data_backup_option_runonce', $data_backups_new ); |
| 611 | 611 | } else { |
| @@ -647,9 +647,9 @@ | ||
| 647 | 647 | |
| 648 | 648 | if ( 'local_path' === $device ) { |
| 649 | 649 | $local_path = WPDA::get_option( WPDA::OPTION_DB_LOCAL_PATH ); |
| 650 | 650 | $client_file_name = $local_path . $filename; |
| 651 | - $file = fopen( $client_file_name, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen | |
| 651 | + $file = fopen( $client_file_name, 'w' ); // phpcs:ignore | |
| 652 | 652 | $wpda_export = new WPDA_Export_Sql(); |
| 653 | 653 | $wpda_export->set_output_stream( $file ); |
| 654 | 654 | $wpda_export->export_with_arguments( |
| 655 | 655 | 'on', |
| @@ -658,19 +658,19 @@ | ||
| 658 | 658 | $schema, |
| 659 | 659 | $tables, |
| 660 | 660 | 'table' |
| 661 | 661 | ); |
| 662 | - fclose( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose | |
| 662 | + fclose( $file ); // phpcs:ignore | |
| 663 | 663 | $keep_counting = 0; |
| 664 | 664 | $files_sorted = array(); |
| 665 | 665 | foreach ( glob( $local_path . "wpda-data-backup-$backupid-*.sql" ) as $filename ) { |
| 666 | - array_push( $files_sorted, $filename );//phpcs:ignore - 8.1 proof | |
| 666 | + array_push( $files_sorted, $filename ); // phpcs:ignore -- 8.1 proof | |
| 667 | 667 | } |
| 668 | - rsort( $files_sorted );//phpcs:ignore - 8.1 proof | |
| 668 | + rsort( $files_sorted ); // phpcs:ignore -- 8.1 proof | |
| 669 | 669 | foreach ( $files_sorted as $file ) { |
| 670 | 670 | $keep_counting ++; |
| 671 | 671 | if ( $keep_counting > (int) $keep ) { |
| 672 | - unlink( $file ); | |
| 672 | + unlink( $file ); // phpcs:ignore | |
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | } elseif ( 'dropbox' === $device ) { |
| 676 | 676 | // To use a stream for Dropbox we first need to write the export to a temporary file. |
| @@ -722,12 +722,12 @@ | ||
| 722 | 722 | } |
| 723 | 723 | $zip->addFile( stream_get_meta_data( $temporary_file )['uri'], $filename ); |
| 724 | 724 | $zip->close(); |
| 725 | 725 | |
| 726 | - $zpf = fopen( $zipfile, 'r' ); | |
| 726 | + $zpf = fopen( $zipfile, 'r' ); // phpcs:ignore | |
| 727 | 727 | WPDA_Remote_Call::post( |
| 728 | 728 | 'https://content.dropboxapi.com/2/files/upload', |
| 729 | - fread( $zpf, filesize( $zipfile ) ), | |
| 729 | + fread( $zpf, filesize( $zipfile ) ), // phpcs:ignore | |
| 730 | 730 | false, |
| 731 | 731 | array( |
| 732 | 732 | 'Authorization' => "Bearer $client_access_token", |
| 733 | 733 | 'Content-Type' => 'application/octet-stream', |
| @@ -737,9 +737,9 @@ | ||
| 737 | 737 | } else { |
| 738 | 738 | fseek( $temporary_file, 0 ); |
| 739 | 739 | WPDA_Remote_Call::post( |
| 740 | 740 | 'https://content.dropboxapi.com/2/files/upload', |
| 741 | - 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 | |
| 742 | 742 | false, |
| 743 | 743 | array( |
| 744 | 744 | 'Authorization' => "Bearer $client_access_token", |
| 745 | 745 | 'Content-Type' => 'application/octet-stream', |
| @@ -775,11 +775,11 @@ | ||
| 775 | 775 | if ( isset( $body_content['matches'] ) ) { |
| 776 | 776 | $keep_counting = 0; |
| 777 | 777 | $files_sorted = array(); |
| 778 | 778 | foreach ( $body_content['matches'] as $match ) { |
| 779 | - 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 | |
| 780 | 780 | } |
| 781 | - rsort( $files_sorted );//phpcs:ignore - 8.1 proof | |
| 781 | + rsort( $files_sorted ); // phpcs:ignore -- 8.1 proof | |
| 782 | 782 | foreach ( $files_sorted as $file ) { |
| 783 | 783 | $keep_counting++; |
| 784 | 784 | if ( $keep_counting > (int) $keep ) { |
| 785 | 785 | // Remove outdated files. |
| @@ -817,9 +817,9 @@ | ||
| 817 | 817 | if ( ! isset( $_REQUEST['backupid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 818 | 818 | $this->show_wp_cron(); |
| 819 | 819 | $msg = new WPDA_Message_Box( |
| 820 | 820 | array( |
| 821 | - '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' ), | |
| 822 | 822 | 'message_type' => 'error', |
| 823 | 823 | 'message_is_dismissible' => false, |
| 824 | 824 | ) |
| 825 | 825 | ); |
| @@ -831,9 +831,9 @@ | ||
| 831 | 831 | if ( ! isset( $_REQUEST['interval'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 832 | 832 | $this->show_wp_cron(); |
| 833 | 833 | $msg = new WPDA_Message_Box( |
| 834 | 834 | array( |
| 835 | - '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' ), | |
| 836 | 836 | 'message_type' => 'error', |
| 837 | 837 | 'message_is_dismissible' => false, |
| 838 | 838 | ) |
| 839 | 839 | ); |
| @@ -845,9 +845,9 @@ | ||
| 845 | 845 | if ( ! isset( $_REQUEST['keep'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 846 | 846 | $this->show_wp_cron(); |
| 847 | 847 | $msg = new WPDA_Message_Box( |
| 848 | 848 | array( |
| 849 | - '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' ), | |
| 850 | 850 | 'message_type' => 'error', |
| 851 | 851 | 'message_is_dismissible' => false, |
| 852 | 852 | ) |
| 853 | 853 | ); |
| @@ -859,9 +859,9 @@ | ||
| 859 | 859 | if ( ! isset( $_REQUEST['device'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 860 | 860 | $this->show_wp_cron(); |
| 861 | 861 | $msg = new WPDA_Message_Box( |
| 862 | 862 | array( |
| 863 | - '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' ), | |
| 864 | 864 | 'message_type' => 'error', |
| 865 | 865 | 'message_is_dismissible' => false, |
| 866 | 866 | ) |
| 867 | 867 | ); |
| @@ -873,9 +873,9 @@ | ||
| 873 | 873 | if ( ! isset( $_REQUEST['wpda_table_name_export'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 874 | 874 | $this->show_wp_cron(); |
| 875 | 875 | $msg = new WPDA_Message_Box( |
| 876 | 876 | array( |
| 877 | - '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' ), | |
| 878 | 878 | 'message_type' => 'error', |
| 879 | 879 | 'message_is_dismissible' => false, |
| 880 | 880 | ) |
| 881 | 881 | ); |
| @@ -902,13 +902,13 @@ | ||
| 902 | 902 | 'keep' => $keep, |
| 903 | 903 | 'schema_name' => $schema_name, |
| 904 | 904 | 'tables' => $request_tables, |
| 905 | 905 | ); |
| 906 | - array_push( $data_backups, $data_backup );//phpcs:ignore - 8.1 proof | |
| 906 | + array_push( $data_backups, $data_backup ); // phpcs:ignore -- 8.1 proof | |
| 907 | 907 | if ( ! update_option( 'wpda_data_backup_option_runonce', $data_backups ) ) { |
| 908 | 908 | $msg = new WPDA_Message_Box( |
| 909 | 909 | array( |
| 910 | - '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' ), | |
| 911 | 911 | 'message_type' => 'error', |
| 912 | 912 | 'message_is_dismissible' => false, |
| 913 | 913 | ) |
| 914 | 914 | ); |
| @@ -921,9 +921,9 @@ | ||
| 921 | 921 | ) |
| 922 | 922 | ) { |
| 923 | 923 | $msg = new WPDA_Message_Box( |
| 924 | 924 | array( |
| 925 | - 'message_text' => __( 'Backup failed', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput | |
| 925 | + 'message_text' => __( 'Backup failed', 'wp-data-access' ), | |
| 926 | 926 | 'message_type' => 'error', |
| 927 | 927 | 'message_is_dismissible' => false, |
| 928 | 928 | ) |
| 929 | 929 | ); |
| @@ -932,15 +932,15 @@ | ||
| 932 | 932 | } |
| 933 | 933 | ?> |
| 934 | 934 | <div class="wrap"> |
| 935 | 935 | <h1 class="wp-heading-inline"> |
| 936 | - <?php echo __( 'Data Backup' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 936 | + <?php esc_html_e( 'Data Backup', 'wp-data-access' ); ?> | |
| 937 | 937 | </h1> |
| 938 | - <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> | |
| 939 | 939 | <p> |
| 940 | 940 | <a href="?page=wpda&page_action=wpda_backup" class="button"> |
| 941 | 941 | <i class="fas fa-angle-left wpda_icon_on_button"></i> |
| 942 | - <?php echo __( 'List' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 942 | + <?php esc_html_e( 'List', 'wp-data-access' ); ?> | |
| 943 | 943 | </a> |
| 944 | 944 | </p> |
| 945 | 945 | </div> |
| 946 | 946 | <?php |
| @@ -954,9 +954,9 @@ | ||
| 954 | 954 | if ( $data_backup['id'] === $backupid ) { |
| 955 | 955 | $this->show_wp_cron(); |
| 956 | 956 | $msg = new WPDA_Message_Box( |
| 957 | 957 | array( |
| 958 | - 'message_text' => __( 'Backup id already exists', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput | |
| 958 | + 'message_text' => __( 'Backup id already exists', 'wp-data-access' ), | |
| 959 | 959 | 'message_type' => 'error', |
| 960 | 960 | 'message_is_dismissible' => false, |
| 961 | 961 | ) |
| 962 | 962 | ); |
| @@ -972,14 +972,14 @@ | ||
| 972 | 972 | 'keep' => $keep, |
| 973 | 973 | 'schema_name' => $schema_name, |
| 974 | 974 | 'tables' => $request_tables, |
| 975 | 975 | ); |
| 976 | - array_push( $data_backups, $data_backup );//phpcs:ignore - 8.1 proof | |
| 976 | + array_push( $data_backups, $data_backup ); // phpcs:ignore -- 8.1 proof | |
| 977 | 977 | if ( ! update_option( 'wpda_data_backup_option', $data_backups ) ) { |
| 978 | 978 | $this->show_wp_cron(); |
| 979 | 979 | $msg = new WPDA_Message_Box( |
| 980 | 980 | array( |
| 981 | - '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' ), | |
| 982 | 982 | 'message_type' => 'error', |
| 983 | 983 | 'message_is_dismissible' => false, |
| 984 | 984 | ) |
| 985 | 985 | ); |
| @@ -1016,9 +1016,9 @@ | ||
| 1016 | 1016 | |
| 1017 | 1017 | if ( false === $unschedule ) { |
| 1018 | 1018 | $msg = new WPDA_Message_Box( |
| 1019 | 1019 | array( |
| 1020 | - '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' ), | |
| 1021 | 1021 | 'message_type' => 'error', |
| 1022 | 1022 | 'message_is_dismissible' => false, |
| 1023 | 1023 | ) |
| 1024 | 1024 | ); |
| @@ -1025,9 +1025,9 @@ | ||
| 1025 | 1025 | $msg->box(); |
| 1026 | 1026 | } else { |
| 1027 | 1027 | $msg = new WPDA_Message_Box( |
| 1028 | 1028 | array( |
| 1029 | - 'message_text' => __( 'Deleted data backup schedule', 'wp-data-access' ), // phpcs:ignore WordPress.Security.EscapeOutput | |
| 1029 | + 'message_text' => __( 'Deleted data backup schedule', 'wp-data-access' ), | |
| 1030 | 1030 | ) |
| 1031 | 1031 | ); |
| 1032 | 1032 | $msg->box(); |
| 1033 | 1033 | // Remove job from queue. |
| @@ -1034,9 +1034,9 @@ | ||
| 1034 | 1034 | $data_backups = get_option( 'wpda_data_backup_option' ); |
| 1035 | 1035 | $data_backups_new = array(); |
| 1036 | 1036 | foreach ( $data_backups as $data_backup ) { |
| 1037 | 1037 | if ( $data_backup['id'] !== $backupid ) { |
| 1038 | - 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 | |
| 1039 | 1039 | } |
| 1040 | 1040 | } |
| 1041 | 1041 | update_option( 'wpda_data_backup_option', $data_backups_new ); |
| 1042 | 1042 | } |
| @@ -1055,9 +1055,9 @@ | ||
| 1055 | 1055 | $backupid = sanitize_text_field( wp_unslash( $_REQUEST['backupid'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 1056 | 1056 | } else { |
| 1057 | 1057 | $msg = new WPDA_Message_Box( |
| 1058 | 1058 | array( |
| 1059 | - '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' ), | |
| 1060 | 1060 | 'message_type' => 'error', |
| 1061 | 1061 | 'message_is_dismissible' => false, |
| 1062 | 1062 | ) |
| 1063 | 1063 | ); |
| @@ -1067,9 +1067,9 @@ | ||
| 1067 | 1067 | $wpda_table_name_export = WPDA::sanitize_text_field_array( $_REQUEST['wpda_table_name_export'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ,WordPress.Security.NonceVerification |
| 1068 | 1068 | } else { |
| 1069 | 1069 | $msg = new WPDA_Message_Box( |
| 1070 | 1070 | array( |
| 1071 | - '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' ), | |
| 1072 | 1072 | 'message_type' => 'error', |
| 1073 | 1073 | 'message_is_dismissible' => false, |
| 1074 | 1074 | ) |
| 1075 | 1075 | ); |
| @@ -1079,9 +1079,9 @@ | ||
| 1079 | 1079 | $interval = sanitize_text_field( wp_unslash( $_REQUEST['interval'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 1080 | 1080 | } else { |
| 1081 | 1081 | $msg = new WPDA_Message_Box( |
| 1082 | 1082 | array( |
| 1083 | - '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' ), | |
| 1084 | 1084 | 'message_type' => 'error', |
| 1085 | 1085 | 'message_is_dismissible' => false, |
| 1086 | 1086 | ) |
| 1087 | 1087 | ); |
| @@ -1091,9 +1091,9 @@ | ||
| 1091 | 1091 | $keep = sanitize_text_field( wp_unslash( $_REQUEST['keep'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 1092 | 1092 | } else { |
| 1093 | 1093 | $msg = new WPDA_Message_Box( |
| 1094 | 1094 | array( |
| 1095 | - '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' ), | |
| 1096 | 1096 | 'message_type' => 'error', |
| 1097 | 1097 | 'message_is_dismissible' => false, |
| 1098 | 1098 | ) |
| 1099 | 1099 | ); |
| @@ -1103,9 +1103,9 @@ | ||
| 1103 | 1103 | $device = sanitize_text_field( wp_unslash( $_REQUEST['device'] ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 1104 | 1104 | } else { |
| 1105 | 1105 | $msg = new WPDA_Message_Box( |
| 1106 | 1106 | array( |
| 1107 | - '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' ), | |
| 1108 | 1108 | 'message_type' => 'error', |
| 1109 | 1109 | 'message_is_dismissible' => false, |
| 1110 | 1110 | ) |
| 1111 | 1111 | ); |
| @@ -1120,9 +1120,9 @@ | ||
| 1120 | 1120 | $timestamp = wp_next_scheduled( 'wpda_data_backup', array( $backupid ) ); |
| 1121 | 1121 | if ( false === wp_unschedule_event( $timestamp, 'wpda_data_backup', array( $backupid ) ) ) { |
| 1122 | 1122 | $msg = new WPDA_Message_Box( |
| 1123 | 1123 | array( |
| 1124 | - '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' ), | |
| 1125 | 1125 | 'message_type' => 'error', |
| 1126 | 1126 | 'message_is_dismissible' => false, |
| 1127 | 1127 | ) |
| 1128 | 1128 | ); |
| @@ -1132,9 +1132,9 @@ | ||
| 1132 | 1132 | $data_backups = get_option( 'wpda_data_backup_option' ); |
| 1133 | 1133 | $data_backups_new = array(); |
| 1134 | 1134 | foreach ( $data_backups as $data_backup ) { |
| 1135 | 1135 | if ( $data_backup['id'] !== $backupid ) { |
| 1136 | - 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 | |
| 1137 | 1137 | } else { |
| 1138 | 1138 | $data_backup_updated = array( |
| 1139 | 1139 | 'id' => $backupid, |
| 1140 | 1140 | 'keep' => $keep, |
| @@ -1141,9 +1141,9 @@ | ||
| 1141 | 1141 | 'device' => $device, |
| 1142 | 1142 | 'schema_name' => $schema_name, |
| 1143 | 1143 | 'tables' => $wpda_table_name_export, |
| 1144 | 1144 | ); |
| 1145 | - 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 | |
| 1146 | 1146 | } |
| 1147 | 1147 | } |
| 1148 | 1148 | update_option( 'wpda_data_backup_option', $data_backups_new ); |
| 1149 | 1149 | // Reschedule job with new arguments. |