ERROR | Detected usage of a non-sanitized input variable: $_POST
Sometimes you get an error like this when the data really is being sanitized, but it requires special handling because it is a multi-dimensional array.
<?php
$_POST['announcement']['display'] = array ( 'verticals' => array ( 0 => 'life', 1 => 'politics', ), )
$taxonomies = isset( $_POST['announcement']['display'] ) ? wp_unslash( $_POST['announcement']['display'] ) : array(); $announcement['display'] = array();
if ( is_array( $taxonomies ) ) {
foreach ( $taxonomies as $taxonomy => $taxonomy_terms ) {
foreach ( $taxonomy_terms as $taxonomy_term ) {
$announcement['display'][ $taxonomy ][] = sanitize_text_field( $taxonomy_term );
}
}
}
?>