Skip to content

Commit

Permalink
improve h::get()
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills authored Apr 15, 2024
1 parent f3920d2 commit a35ec02
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/Traits/Common_Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ trait Common_Helpers {
* @param mixed $default
* @return mixed
*/
public static function get ( &$var, $default = null ) {
return $var ?? $default;
public static function get ( &$var, $default = null, $clean = true ) {
$value = isset( $var ) ? $var : $default;
return $clean && is_scalar( $value ) ? \sanitize_text_field( $value ) : $value;
}

/**
Expand Down

0 comments on commit a35ec02

Please sign in to comment.