本文整理汇总了PHP中wp_cache_init函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_init函数的具体用法?PHP wp_cache_init怎么用?PHP wp_cache_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_cache_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updated_active_languages
private function updated_active_languages()
{
global $sitepress;
wp_cache_init();
icl_cache_clear();
$this->refresh_active_lang_cache(wpml_get_setting_filter(false, 'default_language'));
wpml_reload_active_languages_setting(true);
$active_langs = $sitepress->get_active_languages(true);
$this->maybe_move_setup(3);
if (count($active_langs) > 1) {
icl_set_setting('dont_show_help_admin_notice', true);
}
}
开发者ID:pcuervo,项目名称:odc,代码行数:13,代码来源:wpml-installation.class.php
示例17: wp_cache_get_ob
function wp_cache_get_ob(&$buffer)
{
global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize, $supercacheonly;
global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
if (isset($wp_cache_mfunc_enabled) == false) {
$wp_cache_mfunc_enabled = 0;
}
$new_cache = true;
$wp_cache_meta = '';
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($buffer == '') {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins.");
}
}
if ($wp_cache_404 && false == apply_filters('wpsupercache_404', false)) {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("404 file not found not cached", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. 404.");
}
}
if (!preg_match(apply_filters('wp_cache_eof_tags', '/(<\\/html>|<\\/rss>|<\\/feed>|<\\/urlset|<\\?xml)/i'), $buffer)) {
$new_cache = false;
if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("No closing html tag. Not caching.", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme.");
}
} else {
wp_cache_debug("robots.txt detected. Not caching.", 2);
}
}
if (!$new_cache) {
return wp_cache_maybe_dynamic($buffer);
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
wp_cache_add_to_buffer($buffer, "Dynamic page generated in {$duration} seconds.");
if (!wp_cache_writers_entry()) {
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Could not get mutex lock.");
wp_cache_debug("Could not get mutex lock. Not caching.", 1);
return wp_cache_maybe_dynamic($buffer);
}
if ($wp_cache_not_logged_in && is_feed()) {
wp_cache_debug("Feed detected. Writing legacy cache files.", 5);
$wp_cache_not_logged_in = false;
}
$home_url = parse_url(trailingslashit(get_bloginfo('url')));
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url['host']);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
wp_cache_debug("Supercache disabled: GET or feed detected or disabled by config.", 2);
$super_cache_enabled = false;
}
$tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
$supercacheonly = false;
if ($super_cache_enabled) {
if (wp_cache_get_cookies_values() == '' && empty($_GET)) {
wp_cache_debug("Anonymous user detected. Only creating Supercache file.", 3);
$supercacheonly = true;
}
}
$cache_error = '';
if ($wp_cache_not_logged_in && wp_cache_get_cookies_values() != '') {
$super_cache_enabled = false;
$cache_enabled = false;
$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
wp_cache_debug('Not caching for known user.', 5);
}
if ($wp_cache_object_cache) {
// half on mode when using the object cache
if (wp_cache_get_cookies_values() != '') {
$cache_enabled = false;
$cache_error = 'Known User and using object. Only anonymous users cached.';
}
$super_cache_enabled = false;
$supercacheonly = false;
wp_cache_init();
// PHP5 destroys objects during shutdown
}
if (!$cache_enabled) {
wp_cache_debug('Cache is not enabled. Sending buffer to browser.', 5);
wp_cache_writers_exit();
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Check your settings page. {$cache_error}");
if ($wp_cache_mfunc_enabled == 1) {
global $wp_super_cache_late_init;
if (false == isset($wp_super_cache_late_init) || isset($wp_super_cache_late_init) && $wp_super_cache_late_init == 0) {
wp_cache_add_to_buffer($buffer, 'Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details.');
}
}
return wp_cache_maybe_dynamic($buffer);
//.........这里部分代码省略.........
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:101,代码来源:wp-cache-phase2.php
示例18: test_wp_cache_init
function test_wp_cache_init()
{
$new_blank_cache_object = new WP_Object_Cache();
wp_cache_init();
global $wp_object_cache;
if (wp_using_ext_object_cache()) {
// External caches will contain property values that contain non-matching resource IDs
$this->assertInstanceOf('WP_Object_Cache', $wp_object_cache);
} else {
$this->assertEquals($wp_object_cache, $new_blank_cache_object);
}
}
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:12,代码来源:cache.php
示例19: resolve
public static function resolve( $url ) {
// Reset IP address and transport layer
delete_option( AI1WM_URL_IP );
delete_option( AI1WM_URL_TRANSPORT );
// Set secret
$secret_key = get_option( AI1WM_SECRET_KEY );
// Set scheme
$scheme = parse_url( $url, PHP_URL_SCHEME );
// Set host name
$host = parse_url( $url, PHP_URL_HOST );
// Set server IP address
if ( ! empty( $_SERVER['SERVER_ADDR'] ) ) {
$ip = $_SERVER['SERVER_ADDR'];
} else if ( ! empty( $_SERVER['LOCAL_ADDR'] ) ) {
$ip = $_SERVER['LOCAL_ADDR'];
} else {
$ip = '127.0.0.1';
}
// Set domain IP address
$domain = gethostbyname( $host );
// HTTP resolve
foreach ( array( 'ai1wm', 'curl' ) as $transport ) {
foreach ( array( $ip, $domain, $host ) as $ip ) {
// Set transport
Ai1wm_Http::$transports = array( $transport );
// HTTP request
Ai1wm_Http::request( $url, $ip, array(
'secret_key' => $secret_key,
'url_ip' => $ip,
'url_transport' => $transport
) );
// HTTP response
for ( $i = 0; $i < 5; $i++, sleep( 1 ) ) {
// Initialize empty WP cache
wp_cache_init();
// Is valid transport layer?
if ( get_option( AI1WM_URL_IP ) && get_option( AI1WM_URL_TRANSPORT ) ) {
return;
}
}
}
}
// No connection
throw new Ai1wm_Http_Exception( __(
'There was a problem while reaching your server.<br />' .
'Contact <a href="mailto:[email protected]">[email protected]</a> for assistance.',
AI1WM_PLUGIN_NAME
) );
}
开发者ID:jknowles94,项目名称:Work-examples,代码行数:62,代码来源:class-ai1wm-http.php
示例20: restore_current_blog
function restore_current_blog()
{
global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user;
if (!$switched) {
return false;
}
$blog = array_pop($switched_stack);
if ($blog_id == $blog) {
return false;
}
$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 (is_object($current_user)) {
$current_user->_init_caps();
}
wp_cache_init();
if (function_exists('wp_cache_add_global_groups')) {
wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
}
do_action('switch_blog', $blog_id, $prev_blog_id);
$switched = false;
return true;
}
开发者ID:jinpingv,项目名称:website_wrapper,代码行数:35,代码来源:wpmu-functions.php
注:本文中的wp_cache_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论