Skip to content

Commit

Permalink
feat: Add array sanitizer function
Browse files Browse the repository at this point in the history
  • Loading branch information
hmohammadi committed Nov 14, 2021
1 parent 9031443 commit 2872af3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,28 @@ function ezpz_tweaks_wp_roles_array(): array {
return $roles;
}

function ezpz_tweaks_get_google_font_name($font) {
function ezpz_tweaks_get_google_font_name( $font ) {
$font = str_replace( '+', ' ', $font );
$font = explode( ':', $font );

return $font[0];
}

/**
* Recursive sanitation for an array
*
* @param $array
*
* @return mixed
*/
function ezpz_tweaks_recursive_sanitize( $array ) {
foreach ( $array as $key => &$value ) {
if ( is_array( $value ) ) {
$value = ezpz_tweaks_recursive_sanitize( $value );
} else {
$value = sanitize_text_field( $value );
}
}

return $array;
}

0 comments on commit 2872af3

Please sign in to comment.