WordPress at a glance

wp_reset_vars() WP 1.0

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 '' if neither is defined.

No Hooks.

Return

Nothing (null).

Usage

wp_reset_vars( $vars );
$vars(array) (required)
An array of globals to reset.

Code of wp_reset_vars: wp-admin/includes/misc.php VER 5.0.1

<?php
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 ];
		}
	}
}

Related Functions

From tag: query

More from category: Helper Functions

No comments
    Hello, !     Log In . Register