当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_cache_init函数代码示例

本文整理汇总了PHP中wp_cache_init函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_init函数的具体用法?PHP wp_cache_init怎么用?PHP wp_cache_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_cache_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: icl_reset_wpml

function icl_reset_wpml($blog_id = false)
{
    global $wpdb, $sitepress_settings;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'resetwpml') {
        check_admin_referer('resetwpml');
    }
    if (empty($blog_id)) {
        $blog_id = isset($_POST['id']) ? $_POST['id'] : $wpdb->blogid;
    }
    if ($blog_id || !function_exists('is_multisite') || !is_multisite()) {
        if (function_exists('is_multisite') && is_multisite()) {
            switch_to_blog($blog_id);
        }
        wp_clear_scheduled_hook('update_wpml_config_index');
        $icl_tables = array($wpdb->prefix . 'icl_languages', $wpdb->prefix . 'icl_languages_translations', $wpdb->prefix . 'icl_translations', $wpdb->prefix . 'icl_translation_status', $wpdb->prefix . 'icl_translate_job', $wpdb->prefix . 'icl_translate', $wpdb->prefix . 'icl_locale_map', $wpdb->prefix . 'icl_flags', $wpdb->prefix . 'icl_content_status', $wpdb->prefix . 'icl_core_status', $wpdb->prefix . 'icl_node', $wpdb->prefix . 'icl_strings', $wpdb->prefix . 'icl_string_packages', $wpdb->prefix . 'icl_translation_batches', $wpdb->prefix . 'icl_string_translations', $wpdb->prefix . 'icl_string_status', $wpdb->prefix . 'icl_string_positions', $wpdb->prefix . 'icl_message_status', $wpdb->prefix . 'icl_reminders');
        foreach ($icl_tables as $icl_table) {
            $wpdb->query("DROP TABLE IF EXISTS " . $icl_table);
        }
        delete_option('icl_sitepress_settings');
        delete_option('icl_sitepress_version');
        delete_option('_icl_cache');
        delete_option('_icl_admin_option_names');
        delete_option('wp_icl_translators_cached');
        delete_option('wpml32_icl_non_translators_cached');
        delete_option('WPLANG');
        delete_option('wpml-package-translation-db-updates-run');
        delete_option('wpml-package-translation-refresh-required');
        delete_option('wpml-package-translation-string-packages-table-updated');
        delete_option('wpml-package-translation-string-table-updated');
        delete_option('icl_translation_jobs_basket');
        delete_option('widget_icl_lang_sel_widget');
        delete_option('icl_admin_messages');
        delete_option('icl_adl_settings');
        delete_option('wpml_tp_com_log');
        delete_option('wpml_config_index');
        delete_option('wpml_config_index_updated');
        delete_option('wpml_config_files_arr');
        $sitepress_settings = null;
        wp_cache_init();
        $wpmu_sitewide_plugins = (array) maybe_unserialize(get_site_option('active_sitewide_plugins'));
        if (!isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) {
            $file = plugin_basename(WP_PLUGIN_DIR . '/' . ICL_PLUGIN_FOLDER . '/sitepress.php');
            remove_action('deactivate_' . $file, 'icl_sitepress_deactivate');
            deactivate_plugins(basename(ICL_PLUGIN_PATH) . '/sitepress.php');
            $ra = get_option('recently_activated');
            $ra[basename(ICL_PLUGIN_PATH) . '/sitepress.php'] = time();
            update_option('recently_activated', $ra);
        } else {
            update_option('_wpml_inactive', true);
        }
        if (isset($_REQUEST['submit'])) {
            wp_redirect(network_admin_url('admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/network.php&updated=true&action=resetwpml'));
        }
        if (function_exists('is_multisite') && is_multisite()) {
            restore_current_blog();
        }
    }
}
开发者ID:edgarter,项目名称:wecare,代码行数:58,代码来源:functions-troubleshooting.php

示例2: repair_broken_assignments

 /**
  * Runs various database repair and cleanup actions on icl_translations
  *
  * @return int Number of rows in icl_translations that were fixed
  */
 public function repair_broken_assignments()
 {
     $rows_fixed = $this->fix_missing_original();
     $rows_fixed += $this->fix_wrong_source_language();
     $rows_fixed += $this->fix_broken_type_assignments();
     $this->clear_cache();
     wp_cache_init();
     return $rows_fixed;
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:14,代码来源:class-wpml-set-language.php

示例3: run

 /**
  * Runs various database repair and cleanup actions on icl_translations.
  *
  * @return int Number of rows in icl_translations that were fixed
  */
 public function run()
 {
     $rows_fixed = $this->fix_missing_original();
     $rows_fixed += $this->fix_wrong_source_language();
     $rows_fixed += $this->fix_broken_taxonomy_assignments();
     $rows_fixed += $this->fix_broken_post_assignments();
     $rows_fixed += $this->fix_broken_type_assignments();
     icl_cache_clear();
     wp_cache_init();
     return $rows_fixed;
 }
开发者ID:agiper,项目名称:wordpress,代码行数:16,代码来源:class-wpml-fix-type-assignments.php

示例4: ob

 function ob($output)
 {
     if ($this->cancel !== false) {
         return $output;
     }
     // PHP5 and objects disappearing before output buffers?
     wp_cache_init();
     // Remember, $wp_object_cache was clobbered in wp-settings.php so we have to repeat this.
     $this->configure_groups();
     // Do not batcache blank pages (usually they are HTTP redirects)
     $output = trim($output);
     if (empty($output)) {
         return;
     }
     // Construct and save the batcache
     $cache = array('output' => $output, 'time' => time(), 'timer' => $this->timer_stop(false, 3), 'status_header' => $this->status_header, 'version' => $this->url_version);
     if (function_exists('apache_response_headers')) {
         $cache['headers'] = apache_response_headers();
         if (!empty($this->uncached_headers)) {
             foreach ($cache['headers'] as $header => $value) {
                 if (in_array(strtolower($header), $this->uncached_headers)) {
                     unset($cache['headers'][$header]);
                 }
             }
         }
     }
     wp_cache_set($this->key, $cache, $this->group, $this->max_age + $this->seconds + 30);
     // Unlock regeneration
     wp_cache_delete("{$this->url_key}_genlock", $this->group);
     if ($this->cache_control) {
         header('Last-Modified: ' . date('r', $cache['time']), true);
         header("Cache-Control: max-age={$this->max_age}, must-revalidate", false);
     }
     if (!empty($this->headers)) {
         foreach ($this->headers as $k => $v) {
             if (is_array($v)) {
                 header("{$v[0]}: {$v[1]}", false);
             } else {
                 header("{$k}: {$v}", true);
             }
         }
     }
     // Add some debug info just before </head>
     if ($this->debug) {
         $tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n";
         if (false !== ($tag_position = strpos($output, '</head>'))) {
             $tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n";
             $output = substr($output, 0, $tag_position) . $tag . substr($output, $tag_position);
         }
     }
     // Pass output to next ob handler
     return $output;
 }
开发者ID:nb,项目名称:batcache,代码行数:53,代码来源:advanced-cache.php

示例5: execute

	public static function execute( $params ) {
		global $wp_version;

		// Set progress
		Ai1wm_Status::info( __( 'Adding configuration to archive...', AI1WM_PLUGIN_NAME ) );

		// Initialize empty WP cache
		wp_cache_init();

		// Get options
		$options = wp_load_alloptions();

		// Set config
		$config = new Ai1wm_Config;

		// Set Site URL
		if ( isset( $options['siteurl'] ) ) {
			$config->SiteURL = untrailingslashit( $options['siteurl'] );
		} else {
			$config->SiteURL = site_url();
		}

		// Set Home URL
		if ( isset( $options['home'] ) ) {
			$config->HomeURL = untrailingslashit( $options['home'] );
		} else {
			$config->HomeURL = home_url();
		}

		// Set Plugin Version
		$config->Plugin = (object) array( 'Version' => AI1WM_VERSION );

		// Set WordPress Version and Content
		$config->WordPress = (object) array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR );

		// Save package.json file
		$handle = fopen( ai1wm_package_path( $params ), 'w' );
		fwrite( $handle, json_encode( $config ) );
		fclose( $handle );

		// Add package.json file
		$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
		$archive->add_file( ai1wm_package_path( $params ), AI1WM_PACKAGE_NAME );
		$archive->close();

		// Set progress
		Ai1wm_Status::info( __( 'Done adding configuration to archive.', AI1WM_PLUGIN_NAME ) );

		return $params;
	}
开发者ID:jknowles94,项目名称:Work-examples,代码行数:50,代码来源:class-ai1wm-export-config.php

示例6: sync_custom_field

 private function sync_custom_field($term_id_from, $term_id_to, $meta_key)
 {
     $wpdb = $this->sitepress->wpdb();
     $sql = "SELECT meta_value FROM {$wpdb->termmeta} WHERE term_id=%d AND meta_key=%s";
     $values_from = $wpdb->get_col($wpdb->prepare($sql, array($term_id_from, $meta_key)));
     $values_to = $wpdb->get_col($wpdb->prepare($sql, array($term_id_to, $meta_key)));
     $removed = array_diff($values_to, $values_from);
     foreach ($removed as $v) {
         $delete_prepared = $wpdb->prepare("DELETE FROM {$wpdb->termmeta}\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE term_id=%d\n\t\t\t\t\t\t\t\t\t\t\t\tAND meta_key=%s\n\t\t\t\t\t\t\t\t\t\t\t\tAND meta_value=%s", array($term_id_to, $meta_key, $v));
         $wpdb->query($delete_prepared);
     }
     $added = array_diff($values_from, $values_to);
     foreach ($added as $v) {
         $insert_prepared = $wpdb->prepare("INSERT INTO {$wpdb->termmeta}(term_id, meta_key, meta_value)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES(%d, %s, %s)", array($term_id_to, $meta_key, $v));
         $wpdb->query($insert_prepared);
     }
     wp_cache_init();
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:18,代码来源:class-wpml-sync-term-meta-action.php

示例7: loadWPCruft

 public function loadWPCruft()
 {
     define('ABSPATH', dirname(__DIR__));
     define('WPINC', '/wp-includes');
     $dirname = dirname(__DIR__) . '/wp-includes/';
     require_once $dirname . 'cache.php';
     require_once $dirname . 'class-wp-customize-control.php';
     require_once $dirname . 'class-wp-error.php';
     require_once $dirname . 'class-wp-theme.php';
     require_once $dirname . 'class-wp-walker.php';
     require_once $dirname . 'class-wp-widget-factory.php';
     require_once $dirname . 'class-wp-widget.php';
     require_once $dirname . 'formatting.php';
     require_once $dirname . 'kses.php';
     require_once $dirname . 'nav-menu-template.php';
     require_once $dirname . 'script-loader.php';
     require_once $dirname . 'theme.php';
     // require_once($dirname . 'query.php');
     require_once $dirname . 'widgets.php';
     require_once $dirname . 'general-template.php';
     require_once $dirname . 'wp-functions.php';
     require_once $dirname . 'wp-plugin.php';
     wp_cache_init();
     $app = ResourceManager::getApp();
     chdir($app['paths']['themepath']);
     $GLOBALS['config'] = $app['config'];
     $GLOBALS['paths'] = $app['paths'];
     $GLOBALS['request'] = $app['request'];
     $GLOBALS['wp_widget_factory'] = new \WP_Widget_Factory();
     if (file_exists('functions.php')) {
         require_once 'functions.php';
     }
     // Get the theme.yml, if it exists.
     if (is_readable($app['paths']['themepath'] . '/theme.yml')) {
         $yaml = new \Symfony\Component\Yaml\Parser();
         $GLOBALS['theme_config'] = $yaml->parse(file_get_contents($app['paths']['themepath'] . '/theme.yml'));
     }
 }
开发者ID:bobdenotter,项目名称:wordpress-theme,代码行数:38,代码来源:WordpressHelper.php

示例8: execute


//.........这里部分代码省略.........
		// Get URL IP
		$url_ip = get_option( AI1WM_URL_IP );

		// Get URL transport
		$url_transport = get_option( AI1WM_URL_TRANSPORT );

		// Get secret key
		$secret_key = get_option( AI1WM_SECRET_KEY );

		// Get HTTP user
		$auth_user = get_option( AI1WM_AUTH_USER );

		// Get HTTP password
		$auth_password = get_option( AI1WM_AUTH_PASSWORD );

		// Get active ServMask plugins
		$active_servmask_plugins = ai1wm_active_servmask_plugins();

		$old_prefixes = array();
		$new_prefixes = array();

		// Set main table prefixes
		$old_prefixes[] = ai1wm_servmask_prefix( 'mainsite' );
		$new_prefixes[] = ai1wm_table_prefix();

		// Set site table prefixes
		foreach ( $blogs as $blog ) {
			if ( ai1wm_main_site( $blog->Old->Id ) === false ) {
				$old_prefixes[] = ai1wm_servmask_prefix( $blog->Old->Id );
				$new_prefixes[] = ai1wm_table_prefix( $blog->New->Id );
			}
		}

		// Set base table prefixes
		foreach ( $blogs as $blog ) {
			if ( ai1wm_main_site( $blog->Old->Id ) === true ) {
				$old_prefixes[] = ai1wm_servmask_prefix( 'basesite' );
				$new_prefixes[] = ai1wm_table_prefix( $blog->New->Id );
			}
		}

		// Set site table prefixes
		foreach ( $blogs as $blog ) {
			if ( ai1wm_main_site( $blog->Old->Id ) === true ) {
				$old_prefixes[] = ai1wm_servmask_prefix( $blog->Old->Id );
				$new_prefixes[] = ai1wm_table_prefix( $blog->New->Id );
			}
		}

		// Set table prefixes
		$old_prefixes[] = ai1wm_servmask_prefix();
		$new_prefixes[] = ai1wm_table_prefix();

		// Get database client
		if ( empty( $wpdb->use_mysqli ) ) {
			$client = new Ai1wm_Database_Mysql( $wpdb );
		} else {
			$client = new Ai1wm_Database_Mysqli( $wpdb );
		}

		// Set database options
		$client->set_old_table_prefixes( $old_prefixes )
			   ->set_new_table_prefixes( $new_prefixes )
			   ->set_old_replace_values( $old_values )
			   ->set_new_replace_values( $new_values );

		// Flush database
		if ( ( $version = $config->Plugin->Version ) ) {
			if ( $version !== 'develop' && version_compare( $version, '4.10', '<' ) ) {
				$client->set_include_table_prefixes( array( ai1wm_table_prefix() ) );
				$client->flush();
			}
		}

		// Import database
		$client->import( ai1wm_database_path( $params ) );

		// Initialize empty WP cache
		wp_cache_init();

		// Activate plugins
		activate_plugins( $active_servmask_plugins, null, is_multisite() );

		// Set the new URL IP
		update_option( AI1WM_URL_IP, $url_ip );

		// Set the new URL transport
		update_option( AI1WM_URL_TRANSPORT, $url_transport );

		// Set the new secret key value
		update_option( AI1WM_SECRET_KEY, $secret_key );

		// Set the new HTTP user
		update_option( AI1WM_AUTH_USER, $auth_user );

		// Set the new HTTP password
		update_option( AI1WM_AUTH_PASSWORD, $auth_password );

		return $params;
	}
开发者ID:jknowles94,项目名称:Work-examples,代码行数:101,代码来源:class-ai1wm-import-database.php

示例9: min_switch_to_blog

function min_switch_to_blog($blogID)
{
    if ($blogID == $GLOBALS['blog_id']) {
        return true;
    }
    //switch_to_blog($blogID);
    //return true;
    global $wpdb;
    $wpdb->set_blog_id($blogID);
    $GLOBALS['blog_id'] = $blogID;
    wp_cache_init();
    return true;
}
开发者ID:jacobraccuia,项目名称:dailybeatmedia,代码行数:13,代码来源:functions.php

示例10: icl_reset_wpml

function icl_reset_wpml($blog_id = false)
{
    global $wpdb, $sitepress_settings;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'resetwpml') {
        check_admin_referer('resetwpml');
    }
    if (empty($blog_id)) {
        $filtered_id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE);
        $filtered_id = $filtered_id ? $filtered_id : filter_input(INPUT_GET, 'id', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE);
        $blog_id = $filtered_id !== false ? $filtered_id : $wpdb->blogid;
    }
    if ($blog_id || !function_exists('is_multisite') || !is_multisite()) {
        if (function_exists('is_multisite') && is_multisite()) {
            switch_to_blog($blog_id);
        }
        do_action('wpml_reset_plugins_before');
        wp_clear_scheduled_hook('update_wpml_config_index');
        $icl_tables = array($wpdb->prefix . 'icl_languages', $wpdb->prefix . 'icl_languages_translations', $wpdb->prefix . 'icl_translations', $wpdb->prefix . 'icl_translation_status', $wpdb->prefix . 'icl_translate_job', $wpdb->prefix . 'icl_translate', $wpdb->prefix . 'icl_locale_map', $wpdb->prefix . 'icl_flags', $wpdb->prefix . 'icl_content_status', $wpdb->prefix . 'icl_core_status', $wpdb->prefix . 'icl_node', $wpdb->prefix . 'icl_strings', $wpdb->prefix . 'icl_string_packages', $wpdb->prefix . 'icl_translation_batches', $wpdb->prefix . 'icl_string_translations', $wpdb->prefix . 'icl_string_status', $wpdb->prefix . 'icl_string_positions', $wpdb->prefix . 'icl_message_status', $wpdb->prefix . 'icl_reminders');
        foreach ($icl_tables as $icl_table) {
            $wpdb->query("DROP TABLE IF EXISTS " . $icl_table);
        }
        delete_option('icl_sitepress_settings');
        delete_option('icl_sitepress_version');
        delete_option('_icl_cache');
        delete_option('_icl_admin_option_names');
        delete_option('wp_icl_translators_cached');
        delete_option('wpml32_icl_non_translators_cached');
        delete_option('WPLANG');
        delete_option('wpml-package-translation-db-updates-run');
        delete_option('wpml-package-translation-refresh-required');
        delete_option('wpml-package-translation-string-packages-table-updated');
        delete_option('wpml-package-translation-string-table-updated');
        delete_option('icl_translation_jobs_basket');
        delete_option('widget_icl_lang_sel_widget');
        delete_option('icl_admin_messages');
        delete_option('icl_adl_settings');
        delete_option('wpml_tp_com_log');
        delete_option('wpml_config_index');
        delete_option('wpml_config_index_updated');
        delete_option('wpml_config_files_arr');
        $sitepress_settings = null;
        wp_cache_init();
        $wpml_cache_directory = new WPML_Cache_Directory(new WPML_WP_API());
        $wpml_cache_directory->remove();
        do_action('wpml_reset_plugins_after');
        $wpmu_sitewide_plugins = (array) maybe_unserialize(get_site_option('active_sitewide_plugins'));
        if (!isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) {
            $file = plugin_basename(WP_PLUGIN_DIR . '/' . ICL_PLUGIN_FOLDER . '/sitepress.php');
            remove_action('deactivate_' . $file, 'icl_sitepress_deactivate');
            deactivate_plugins(basename(ICL_PLUGIN_PATH) . '/sitepress.php');
            $ra = get_option('recently_activated');
            $ra[basename(ICL_PLUGIN_PATH) . '/sitepress.php'] = time();
            update_option('recently_activated', $ra);
        } else {
            update_option('_wpml_inactive', true);
        }
        if (function_exists('is_multisite') && is_multisite()) {
            restore_current_blog();
        }
    }
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:61,代码来源:functions-troubleshooting.php

示例11: test_wp_cache_init

 public function test_wp_cache_init()
 {
     $new_blank_cache_object = new WP_Object_Cache();
     wp_cache_init();
     global $wp_object_cache;
     // Differs from core tests because we'll have two different Redis sockets
     $this->assertEquals($wp_object_cache->cache, $new_blank_cache_object->cache);
 }
开发者ID:pantheon-systems,项目名称:wp-redis,代码行数:8,代码来源:test-cache.php

示例12: test_password_reset__normal

 /**
  * @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(10 => $ip), $actual, 'Expected IP was not found.');
     $wpdb->query('ROLLBACK TO empty');
     wp_cache_init();
 }
开发者ID:hellerbenjamin,项目名称:login-security-solution,代码行数:16,代码来源:VerifiedIpTest.php

示例13: test_wp_cache_init

 function test_wp_cache_init()
 {
     $new_blank_cache_object = new WP_Object_Cache();
     wp_cache_init();
     global $wp_object_cache;
     $this->assertEquals($wp_object_cache, $new_blank_cache_object);
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:7,代码来源:cache.php

示例14: _reset_wp

/**
 * Reset the WordPress test expectations.
 */
function _reset_wp()
{
    global $wp_test_expectations;
    $wp_test_expectations = array('options' => array(), 'categories' => array(), 'post_categories' => array(), 'get_posts' => array(), 'admin_pages' => array(), 'pages' => array(), 'posts' => array(), 'comments' => array(), 'actions' => array(), 'filters' => array(), 'post_meta' => array(), 'themes' => array(), 'plugin_domains' => array(), 'enqueued_scripts' => array(), 'enqueued_styles' => array(), 'all_tags' => array(), 'post_tags' => array(), 'sidebar_widgets' => array(), 'widget_controls' => array(), 'nonce' => array(), 'wp_widgets' => array(), 'current' => array('is_feed' => false, 'is_home' => false), 'plugin_data' => array(), 'theme' => array('posts' => array()), 'bloginfo' => array(), 'user_capabilities' => array(), 'children' => array(), 'current_user' => null, 'users' => array(), 'user_meta' => array(), 'image_downsize' => array(), 'sites' => array());
    wp_cache_init();
}
开发者ID:rgeyer,项目名称:mockpress,代码行数:9,代码来源:mockpress.php

示例15: restore_current_blog

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;
}
开发者ID:junxuan,项目名称:wordpress,代码行数:54,代码来源:ms-blogs.php


注:本文中的wp_cache_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。