wp_reset_vars

Definition:
function wp_reset_vars( $vars ) {}

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.

Parameters

  • array $vars: An array of globals to reset.

Source code

function wp_reset_vars( $vars ) {

	for ( $i=0; $i<count( $vars ); $i += 1 ) {

		$var = $vars[$i];

		global $$var;



		if ( empty( $_POST[$var] ) ) {

			if ( empty( $_GET[$var] ) )

				$$var = '';

			else

				$$var = $_GET[$var];

		} else {

			$$var = $_POST[$var];

		}

	}

}

4059

wp_reset_query

Definition:
function wp_reset_query() {}

Destroy the previous query and set up a new query.
This should be used after query_posts() and before another query_posts(). This will remove obscure bugs that occur when the previous wp_query object is not destroyed properly before another is set up.

Source code

function wp_reset_query() {

	unset($GLOBALS['wp_query']);

	$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];

	wp_reset_postdata();

}

4057

wp_reset_postdata

Definition:
function wp_reset_postdata() {}

After looping through a separate query, this function restores the $post global to the current post in the main query

Source code

function wp_reset_postdata() {

	global $wp_query;

	if ( !empty($wp_query->post) ) {

		$GLOBALS['post'] = $wp_query->post;

		setup_postdata($wp_query->post);

	}

}

4055

wp_reschedule_event

Definition:
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() {}

Reschedule a recurring event.

Parameters

  • int $timestamp: Timestamp for when to run the event.
  • string $recurrence: How often the event should recur.
  • string $hook: Action hook to execute when cron is run.
  • array $args: Optional. Arguments to pass to the hook’s callback function.

Return values

returns:False on failure. Null when event is rescheduled.

Source code

function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {

	$crons = _get_cron_array();

	$schedules = wp_get_schedules();

	$key = md5(serialize($args));

	$interval = 0;



	// First we try to get it from the schedule

	if ( 0 == $interval )

		$interval = $schedules[$recurrence]['interval'];

	// Now we try to get it from the saved interval in case the schedule disappears

	if ( 0 == $interval )

		$interval = $crons[$timestamp][$hook][$key]['interval'];

	// Now we assume something is wrong and fail to schedule

	if ( 0 == $interval )

		return false;



	$now = time();



	if ( $timestamp >= $now )

		$timestamp = $now + $interval;

	else

		$timestamp = $now + ($interval - (($now - $timestamp) % $interval));



	wp_schedule_event( $timestamp, $recurrence, $hook, $args );

}

4053

wp_remote_retrieve_response_message

Definition:
function wp_remote_retrieve_response_message(&$response) {}

Retrieve only the response message from the raw response.
Will return an empty array if incorrect parameter value is given.

Parameters

  • array $response: HTTP response.
  • &$response

Return values

returns:The response message. Empty string on incorrect parameter given.

Source code

function wp_remote_retrieve_response_message(&$response) {

	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))

		return '';



	return $response['response']['message'];

}

4051