wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_reset_vars › WordPress Function

Since2.0.0
Deprecatedn/a
wp_reset_vars ( $vars )
Parameters:
  • (array) $vars An array of globals to reset.
    Required: Yes
Defined at:
Codex:

Resets global variables based on `$_GET` and `$_POST`.

This function resets global variables based on the names passed in the $vars array to the value of $_POST[$var] or $_GET[$var] or an empty string if neither is defined.


Source

function wp_reset_vars( $vars ) {
	foreach ( $vars as $var ) {
		if ( empty( $_POST[ $var ] ) ) {
			if ( empty( $_GET[ $var ] ) ) {
				$GLOBALS[ $var ] = '';
			} else {
				$GLOBALS[ $var ] = $_GET[ $var ];
			}
		} else {
			$GLOBALS[ $var ] = $_POST[ $var ];
		}
	}
}