rewind_posts

Definition:
function rewind_posts() {}

Rewind the loop posts.

Source code

	function rewind_posts() {

		$this->current_post = -1;

		if ( $this->post_count > 0 ) {

			$this->post = $this->posts[0];

		}

	}

2749

revoke_super_admin

Definition:
function revoke_super_admin( $user_id ) {}

Revokes super admin privileges.

Parameters

  • int $user_id

Defined actions

  • revoke_super_admin
    do_action( 'revoke_super_admin', $user_id );
  • revoked_super_admin
    do_action( 'revoked_super_admin', $user_id );

Source code

function revoke_super_admin( $user_id ) {

	global $super_admins;



	// If global super_admins override is defined, there is nothing to do here.

	if ( isset($super_admins) )

		return false;



	do_action( 'revoke_super_admin', $user_id );



	// Directly fetch site_admins instead of using get_super_admins()

	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );



	$user = new WP_User( $user_id );

	if ( $user->user_email != get_site_option( 'admin_email' ) ) {

		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {

			unset( $super_admins[$key] );

			update_site_option( 'site_admins', $super_admins );

			do_action( 'revoked_super_admin', $user_id );

			return true;

		}

	}

	return false;

}

2747

retrieve_widgets

Definition:
function retrieve_widgets() {}

Source code

function retrieve_widgets() {

	global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;



	$_sidebars_widgets = array();

	$sidebars = array_keys($wp_registered_sidebars);



	unset( $sidebars_widgets['array_version'] );



	$old = array_keys($sidebars_widgets);

	sort($old);

	sort($sidebars);



	if ( $old == $sidebars )

		return;



	// Move the known-good ones first

	foreach ( $sidebars as $id ) {

		if ( array_key_exists( $id, $sidebars_widgets ) ) {

			$_sidebars_widgets[$id] = $sidebars_widgets[$id];

			unset($sidebars_widgets[$id], $sidebars[$id]);

		}

	}



	// if new theme has less sidebars than the old theme

	if ( !empty($sidebars_widgets) ) {

		foreach ( $sidebars_widgets as $lost => $val ) {

			if ( is_array($val) )

				$_sidebars_widgets['wp_inactive_widgets'] = array_merge( (array) $_sidebars_widgets['wp_inactive_widgets'], $val );

		}

	}



	// discard invalid, theme-specific widgets from sidebars

	$shown_widgets = array();

	foreach ( $_sidebars_widgets as $sidebar => $widgets ) {

		if ( !is_array($widgets) )

			continue;



		$_widgets = array();

		foreach ( $widgets as $widget ) {

			if ( isset($wp_registered_widgets[$widget]) )

				$_widgets[] = $widget;

		}

		$_sidebars_widgets[$sidebar] = $_widgets;

		$shown_widgets = array_merge($shown_widgets, $_widgets);

	}



	$sidebars_widgets = $_sidebars_widgets;

	unset($_sidebars_widgets, $_widgets);



	// find hidden/lost multi-widget instances

	$lost_widgets = array();

	foreach ( $wp_registered_widgets as $key => $val ) {

		if ( in_array($key, $shown_widgets, true) )

			continue;



		$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);



		if ( 2 > (int) $number )

			continue;



		$lost_widgets[] = $key;

	}



	$sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);

	wp_set_sidebars_widgets($sidebars_widgets);

}

2745

restore_current_blog

Definition:
function restore_current_blog() {}

Restore the current blog, after calling switch_to_blog()

Return values

returns:True on success, False if we’re already on the current blog

Defined actions

  • switch_blog
    do_action( 'switch_blog', $blog, $blog );
  • switch_blog
    do_action('switch_blog', $blog_id, $prev_blog_id);

Source code

function restore_current_blog() {

	global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;



	if ( !$switched )

		return false;



	if ( !is_array( $switched_stack ) )

		return false;



	$blog = array_pop( $switched_stack );

	if ( $blog_id == $blog ) {

		do_action( 'switch_blog', $blog, $blog );

		/* If we still have items in the switched stack, consider ourselves still 'switched' */

		$switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 );

		return true;

	}



	$wpdb->set_blog_id($blog);

	$prev_blog_id = $blog_id;

	$blog_id = $blog;

	$table_prefix = $wpdb->prefix;



	if ( is_object( $wp_roles ) ) {

		$wpdb->suppress_errors();

		if ( method_exists( $wp_roles ,'_init' ) )

			$wp_roles->_init();

		elseif ( method_exists( $wp_roles, '__construct' ) )

			$wp_roles->__construct();

		$wpdb->suppress_errors( false );

	}



	if ( did_action('init') ) {

		$current_user = wp_get_current_user();

		if ( is_object( $current_user ) )

			$current_user->for_blog( $blog_id );

	}



	if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )

		$global_groups = $wp_object_cache->global_groups;

	else

		$global_groups = false;



	wp_cache_init();

	if ( function_exists('wp_cache_add_global_groups') ) {

		if ( is_array( $global_groups ) )

			wp_cache_add_global_groups( $global_groups );

		else

			wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );

		wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));

	}



	do_action('switch_blog', $blog_id, $prev_blog_id);



	/* If we still have items in the switched stack, consider ourselves still 'switched' */

	$switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 );

	return true;

}

2741