| @@ -1,5 +1,5 @@ | ||
| 1 | -<?php // phpcs:ignore Standard.Category.SniffName.ErrorCode | |
| 1 | +<?php | |
| 2 | 2 | |
| 3 | 3 | namespace WPDataAccess\CSV_Files { |
| 4 | 4 | |
| 5 | 5 | use WPDataAccess\Data_Dictionary\WPDA_List_Columns_Cache; |
| @@ -138,9 +138,9 @@ | ||
| 138 | 138 | // Remove edit action. |
| 139 | 139 | unset( $actions['edit'] ); |
| 140 | 140 | |
| 141 | 141 | // Add new links to beginning of action list. |
| 142 | - //phpcs:ignore - 8.1 proof | |
| 142 | + // phpcs:ignore -- 8.1 proof | |
| 143 | 143 | $actions = |
| 144 | 144 | array_merge( |
| 145 | 145 | array( 'mapping' => $mapping ), |
| 146 | 146 | array( 'import' => $import ), |
| @@ -166,8 +166,9 @@ | ||
| 166 | 166 | if ( ! empty( $csv_encoding ) ) { |
| 167 | 167 | $csv_encoding_field = "<input type='hidden' name='csv_encoding' value='{$esc_attr( $csv_encoding )}' />"; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed | |
| 170 | 171 | $form = <<< EOT |
| 171 | 172 | <form id='{$esc_attr( $form_id )}' method='post' |
| 172 | 173 | action='?page={$esc_attr( $this->page )}&page_action=wpda_import_csv' |
| 173 | 174 | > |
| @@ -208,9 +209,9 @@ | ||
| 208 | 209 | public function process_bulk_action() { |
| 209 | 210 | if ( 'delete' === $this->current_action() ) { |
| 210 | 211 | // Check if key is available. |
| 211 | 212 | if ( ! isset( $_REQUEST['csv_id'] ) ) { // input var okay. |
| 212 | - wp_die( __( 'ERROR: Invalid URL [missing primary key values]', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 213 | + wp_die( esc_html__( 'ERROR: Invalid URL [missing primary key values]', 'wp-data-access' ) ); | |
| 213 | 214 | } |
| 214 | 215 | $csv_id = sanitize_text_field( wp_unslash( $_REQUEST['csv_id'] ) ); // input var okay. |
| 215 | 216 | |
| 216 | 217 | // Check if delete is allowed. |
| @@ -216,17 +217,17 @@ | ||
| 216 | 217 | // Check if delete is allowed. |
| 217 | 218 | $wp_nonce_action = "wpda-delete-{$this->table_name}-{$csv_id}"; |
| 218 | 219 | $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay. |
| 219 | 220 | if ( ! wp_verify_nonce( $wp_nonce, $wp_nonce_action ) ) { |
| 220 | - wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 221 | + wp_die( esc_html__( 'ERROR: Not authorized', 'wp-data-access' ) ); | |
| 221 | 222 | } |
| 222 | 223 | |
| 223 | 224 | // Delete CSV file and data. |
| 224 | 225 | $row = WPDA_CSV_Uploads_Model::query( $csv_id ); |
| 225 | - if ( is_array( $row ) && 1 === count( $row ) ) {//phpcs:ignore - 8.1 proof | |
| 226 | + if ( is_array( $row ) && 1 === count( $row ) ) { // phpcs:ignore -- 8.1 proof | |
| 226 | 227 | // Silently delete file. |
| 227 | 228 | if ( isset( $row[0]->csv_real_file_name ) ) { |
| 228 | - unlink( WPDA::get_plugin_upload_dir() . $row[0]->csv_real_file_name ); | |
| 229 | + unlink( WPDA::get_plugin_upload_dir() . $row[0]->csv_real_file_name ); // phpcs:ignore | |
| 229 | 230 | } |
| 230 | 231 | |
| 231 | 232 | // Delete record. |
| 232 | 233 | $next_row_to_be_deleted['csv_id'] = $csv_id; |
| @@ -263,13 +264,13 @@ | ||
| 263 | 264 | // Check if delete is allowed. |
| 264 | 265 | $wp_nonce_action = "wpda-delete-{$this->table_name}"; |
| 265 | 266 | $wp_nonce = isset( $_REQUEST['_wpnonce2'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce2'] ) ) : ''; // input var okay. |
| 266 | 267 | if ( ! wp_verify_nonce( $wp_nonce, $wp_nonce_action ) ) { |
| 267 | - die( __( 'ERROR: Not authorized', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 268 | + die( esc_html__( 'ERROR: Not authorized', 'wp-data-access' ) ); | |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | 271 | $bulk_rows = $_REQUEST['bulk-selected']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput |
| 271 | - //phpcs:ignore - 8.1 proof | |
| 272 | + // phpcs:ignore -- 8.1 proof | |
| 272 | 273 | $no_rows = count( ( array ) $bulk_rows ); // # rows to be deleted. |
| 273 | 274 | |
| 274 | 275 | $rows_to_be_deleted = array(); // Gonna hold rows to be deleted. |
| 275 | 276 | for ( $i = 0; $i < $no_rows; $i ++ ) { |
| @@ -278,9 +279,9 @@ | ||
| 278 | 279 | $row_object = json_decode( stripslashes( stripslashes( $bulk_rows[ $i ] ) ), true ); |
| 279 | 280 | |
| 280 | 281 | // Check if key is available. |
| 281 | 282 | if ( ! isset( $row_object['csv_id'] ) ) { |
| 282 | - wp_die( __( 'ERROR: Invalid URL [missing primary key values]', 'wp-data-access' ) ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 283 | + wp_die( esc_html__( 'ERROR: Invalid URL [missing primary key values]', 'wp-data-access' ) ); | |
| 283 | 284 | } |
| 284 | 285 | |
| 285 | 286 | // Save key. |
| 286 | 287 | $rows_to_be_deleted[ $i ] = $row_object['csv_id']; |
| @@ -291,12 +292,12 @@ | ||
| 291 | 292 | $rows_with_errors = 0; // Number of rows that could not be deleted. |
| 292 | 293 | for ( $i = 0; $i < $no_rows; $i ++ ) { |
| 293 | 294 | // Delete CSV file and data. |
| 294 | 295 | $row = WPDA_CSV_Uploads_Model::query( $rows_to_be_deleted[ $i ] ); |
| 295 | - if ( is_array( $row ) && 1 === count( $row ) ) {//phpcs:ignore - 8.1 proof | |
| 296 | + if ( is_array( $row ) && 1 === count( $row ) ) { // phpcs:ignore -- 8.1 proof | |
| 296 | 297 | // Silently delete file. |
| 297 | 298 | if ( isset( $row[0]->csv_real_file_name ) ) { |
| 298 | - unlink( WPDA::get_plugin_upload_dir() . $row[0]->csv_real_file_name ); | |
| 299 | + unlink( WPDA::get_plugin_upload_dir() . $row[0]->csv_real_file_name ); // phpcs:ignore | |
| 299 | 300 | } |
| 300 | 301 | |
| 301 | 302 | // Delete record. |
| 302 | 303 | $next_row_to_be_deleted['csv_id'] = $rows_to_be_deleted[ $i ]; |