Skip to content

Instantly share code, notes, and snippets.

@techjewel
Created December 22, 2017 05:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techjewel/8613d2a08cd0ee76011689758a150f59 to your computer and use it in GitHub Desktop.
Save techjewel/8613d2a08cd0ee76011689758a150f59 to your computer and use it in GitHub Desktop.
<?php
function ninjaSanitizeTextOrArray( $array_or_string ) {
if ( is_string( $array_or_string ) ) {
$array_or_string = sanitize_text_field( $array_or_string );
} elseif ( is_array( $array_or_string ) ) {
foreach ( $array_or_string as $key => &$value ) {
if ( is_array( $value ) ) {
$value = ninjaSanitizeTextOrArray( $value );
} else {
$value = ninjaSanitizeTextOrArray( $value );
}
}
}
return $array_or_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment