wp_reset_vars

Resets global variables based on $_GET and $_POST.

Description

wp_reset_vars( (array) $vars ); 

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.

Parameters (1)

0. $vars (array)
An array of globals to reset.

Usage

  1. if ( !function_exists( 'wp_reset_vars' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/misc.php'; 
  3.  
  4. // An array of globals to reset. 
  5. $vars = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_reset_vars($vars); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/misc.php  
  1. function wp_reset_vars( $vars ) { 
  2. foreach ( $vars as $var ) { 
  3. if ( empty( $_POST[ $var ] ) ) { 
  4. if ( empty( $_GET[ $var ] ) ) { 
  5. $GLOBALS[ $var ] = ''; 
  6. } else { 
  7. $GLOBALS[ $var ] = $_GET[ $var ]; 
  8. } else { 
  9. $GLOBALS[ $var ] = $_POST[ $var ];