diff --git a/Request.php b/Request.php index ed7e5a3..93374b9 100644 --- a/Request.php +++ b/Request.php @@ -63,6 +63,17 @@ public static function fetch_req_var( $key, $def = null ) { return self::fetch_var( $_REQUEST[ $key ], $def ); } + /** + * Fetch a variable from the $_SERVER superglobal. + * + * @param string $key The key to fetch. + * @param mixed $def The default value. + * @return mixed The fetched value. + */ + public static function fetch_server_var( $key, $def = null ) { + return self::fetch_var( $_SERVER[ $key ], $def ); + } + /** * Fetch, unslash, and clean a variable. * diff --git a/xwp-helper-fns.php b/xwp-helper-fns.php index aab98c8..e0c4e5f 100644 --- a/xwp-helper-fns.php +++ b/xwp-helper-fns.php @@ -224,6 +224,19 @@ function xwp_fetch_req_var( $key, $def = null ) { } endif; +if ( ! function_exists( 'xwp_fetch_server_var' ) ) : + /** + * Get an item of `SERVER` data if set, otherwise return a default value. + * + * @param string $key SERVER key. + * @param string $def Default value. + * @return mixed Value sanitized by xwp_uclean. + */ + function xwp_fetch_server_var( $key, $def = null ) { + return f\Request::fetch_server_var( $key, $def ); + } +endif; + if ( ! function_exists( 'xwp_format_term_name' ) ) : /**