Is there a way to sanitize a $_REQUEST[object] to satisfy the phpcs standards for WordPress? Below is what I have so far but phpcs still errors on the earliest assignment of the request and I cannot figure out how to sanitize without first assigning.
if ( ( isset( $_REQUEST['action'] ) && 'delete' === $_REQUEST['action'] ) || ( isset( $_REQUEST['action2'] ) && 'delete' === $_REQUEST['action2'] ) ) {
$nonce = isset( $_REQUEST['delete_bulk'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete_bulk'] ) ) : '';
if ( wp_verify_nonce( $nonce, 'delete_bulk' ) ) {
if ( isset( $_REQUEST['bulkcheck'] ) ) {
$checks = $_REQUEST['bulkcheck']; // This generates phpcs errors.
$bulkcheck = array();
foreach ( $checks as $key => $val ) {
$bulkcheck[ $key ] = ( isset( $checks[ $key ] ) ) ? sanitize_text_field( wp_unslash( $val ) ) : '';
}
}
$this->quotes_delete_bulk( $bulkcheck );
header( 'Location: ' . get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=My-Plugin' );
} else {
$this->msg = $this->nonce_error();
}
}