/**
  * Cache-safe switching in case any multi-site hiccups might occur.
  * Clears the cache after switching to the given blog to avoid using
  * another blog's cached values.
  * See  wp_cache_reset() in wp-includes/cache.php
  * @see wp_cache_reset()
  * @link http://core.trac.wordpress.org/ticket/14941
  *
  * @param int $blog_id
  */
 public static function switch_to_blog($blog_id)
 {
     switch_to_blog($blog_id);
     if (function_exists('wp_cache_switch_to_blog')) {
         wp_cache_switch_to_blog($blog_id);
         // introduced in WP 3.5.0
     } else {
         wp_cache_reset();
         // deprecated in WP 3.5.0
     }
 }
예제 #2
0
파일: load.php 프로젝트: laiello/qinhan
/**
 * Starts the WordPress object cache.
 *
 * If an object-cache.php file exists in the wp-content directory,
 * it uses that drop-in as an external object cache.
 *
 * @access private
 * @since 3.0.0
 */
function wp_start_object_cache()
{
    global $_wp_using_ext_object_cache;
    $first_init = false;
    if (!function_exists('wp_cache_init')) {
        if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
            require_once WP_CONTENT_DIR . '/object-cache.php';
            $_wp_using_ext_object_cache = true;
        } else {
            require_once ABSPATH . WPINC . '/cache.php';
            $_wp_using_ext_object_cache = false;
        }
        $first_init = true;
    } else {
        if (!$_wp_using_ext_object_cache && file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
            // Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
            // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
            // being set incorrectly. Double check if an external cache exists.
            $_wp_using_ext_object_cache = true;
        }
    }
    // If cache supports reset, reset instead of init if already initialized.
    // Reset signals to the cache that global IDs have changed and it may need to update keys
    // and cleanup caches.
    if (!$first_init && function_exists('wp_cache_reset')) {
        wp_cache_reset();
    } else {
        wp_cache_init();
    }
    if (function_exists('wp_cache_add_global_groups')) {
        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'));
    }
}
예제 #3
0
 /**
  * @depends test_save_verified_ip__overflow
  */
 public function test_password_reset__normal()
 {
     global $wpdb;
     $ip = '3.4.5.6';
     $_SERVER['REMOTE_ADDR'] = $ip;
     $actual = self::$lss->password_reset($this->user, 'some 1 Needs!');
     $this->assertNull($actual, 'password_reset() should return null.');
     // Check the outcome.
     $actual = self::$lss->get_verified_ips($this->user->ID);
     $this->assertSame(array($ip), $actual, 'Expected IP was not found.');
     $wpdb->query('ROLLBACK TO empty');
     wp_cache_reset();
 }
 /**
  * Cache-safe switching in case any multi-site hiccups might occur.
  * Clears the cache after switching to the given blog to avoid using
  * another blog's cached values.
  * See  wp_cache_reset() in wp-includes/cache.php
  * @see wp_cache_reset()
  * @link http://core.trac.wordpress.org/ticket/14941
  *
  * @param int $blog_id
  */
 public static function switch_to_blog($blog_id)
 {
     switch_to_blog($blog_id);
     wp_cache_reset();
 }
예제 #5
0
/**
 * Drop tables and clear data if the plugin is deactivated.
 * This will happen only if the user chooses to delete data upon deactivation.
 */
function affiliates_deactivate($network_wide = false)
{
    if (is_multisite() && $network_wide) {
        if (get_option('aff_delete_network_data', false)) {
            $blog_ids = affiliates_get_blogs();
            foreach ($blog_ids as $blog_id) {
                switch_to_blog($blog_id);
                wp_cache_reset();
                affiliates_cleanup(true);
                restore_current_blog();
            }
        }
    } else {
        affiliates_cleanup();
    }
}
예제 #6
0
파일: load.php 프로젝트: beaucollins/wp
/**
 * Starts the WordPress object cache.
 *
 * If an object-cache.php file exists in the wp-content directory,
 * it uses that drop-in as an external object cache.
 *
 * @access private
 * @since 3.0.0
 */
function wp_start_object_cache()
{
    $first_init = false;
    if (!function_exists('wp_cache_init')) {
        global $_wp_using_ext_object_cache;
        if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
            require_once WP_CONTENT_DIR . '/object-cache.php';
            $_wp_using_ext_object_cache = true;
        } else {
            require_once ABSPATH . WPINC . '/cache.php';
            $_wp_using_ext_object_cache = false;
        }
        $first_init = true;
    }
    // If cache supports reset, reset instead of init if already initialized.
    // Reset signals to the cache that global IDs have changed and it may need to update keys
    // and cleanup caches.
    if (!$first_init && function_exists('wp_cache_reset')) {
        wp_cache_reset();
    } else {
        wp_cache_init();
    }
    if (function_exists('wp_cache_add_global_groups')) {
        wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts'));
        wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
    }
}
예제 #7
0
 /**
  * Clean up for a given blog.
  *
  * @param int $blog_id
  * @param boolean $drop
  */
 public static function delete_blog($blog_id, $drop = false)
 {
     if (is_multisite()) {
         if (self::is_sitewide_plugin()) {
             switch_to_blog($blog_id);
             wp_cache_reset();
             self::cleanup($drop);
             restore_current_blog();
         }
     }
 }