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


PHP Util_Environment::blog_id方法代码示例

本文整理汇总了PHP中Util_Environment::blog_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::blog_id方法的具体用法?PHP Util_Environment::blog_id怎么用?PHP Util_Environment::blog_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util_Environment的用法示例。


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

示例1: log_filename

 /**
  * Return full path to log file for module
  * Path used in priority
  * 1) W3TC_DEBUG_DIR
  * 2) WP_DEBUG_LOG
  * 3) W3TC_CACHE_DIR
  *
  * @param unknown $module
  * @param null    $blog_id
  * @return string
  */
 public static function log_filename($module, $blog_id = null)
 {
     if (is_null($blog_id)) {
         $blog_id = Util_Environment::blog_id();
     }
     $postfix = sprintf('%06d', $blog_id);
     if (defined('W3TC_BLOG_LEVELS')) {
         for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
             $postfix = substr($postfix, strlen($postfix) - 1 - $n, 1) . '/' . $postfix;
         }
     }
     $from_dir = W3TC_CACHE_DIR;
     if (defined('W3TC_DEBUG_DIR') && W3TC_DEBUG_DIR) {
         $dir_path = W3TC_DEBUG_DIR;
         if (!is_dir(W3TC_DEBUG_DIR)) {
             $from_dir = dirname(W3TC_DEBUG_DIR);
         }
     } else {
         $dir_path = Util_Environment::cache_dir('log');
     }
     $filename = $dir_path . '/' . $postfix . '/' . $module . '.log';
     if (!is_dir(dirname($filename))) {
         Util_File::mkdir_from(dirname($filename), $from_dir);
     }
     return $filename;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:37,代码来源:Util_Debug.php

示例2: fix_in_wpadmin

 /**
  * Fixes environment
  *
  * @param Config  $config
  * @throws Util_Environment_Exceptions
  */
 function fix_in_wpadmin($config, $force_all_checks = false)
 {
     $exs = new Util_Environment_Exceptions();
     $fix_on_event = false;
     if (Util_Environment::is_wpmu() && Util_Environment::blog_id() != 0) {
         if (get_transient('w3tc_config_changes') != ($md5_string = $config->get_md5())) {
             $fix_on_event = true;
             set_transient('w3tc_config_changes', $md5_string, 3600);
         }
     }
     // call plugin-related handlers
     foreach ($this->get_handlers($config) as $h) {
         try {
             $h->fix_on_wpadmin_request($config, $force_all_checks);
             if ($fix_on_event) {
                 $this->fix_on_event($config, 'admin_request');
             }
         } catch (Util_Environment_Exceptions $ex) {
             $exs->push($ex);
         }
     }
     try {
         do_action('w3tc_environment_fix_on_wpadmin_request', $config, $force_all_checks);
     } catch (Util_Environment_Exceptions $ex) {
         $exs->push($ex);
     }
     if (count($exs->exceptions()) > 0) {
         throw $exs;
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:36,代码来源:Root_Environment.php

示例3: instance

 /**
  * Returns cache engine instance
  *
  * @param string  $engine
  * @param array   $config
  * @return W3_Cache_Base
  */
 static function instance($engine, $config = array())
 {
     static $instances = array();
     // common configuration data
     if (!isset($config['blog_id'])) {
         $config['blog_id'] = Util_Environment::blog_id();
     }
     $instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
     if (!isset($instances[$instance_key])) {
         switch ($engine) {
             case 'apc':
                 if (function_exists('apcu_store')) {
                     $instances[$instance_key] = new Cache_Apcu($config);
                 } else {
                     if (function_exists('apc_store')) {
                         $instances[$instance_key] = new Cache_Apc($config);
                     }
                 }
                 break;
             case 'eaccelerator':
                 $instances[$instance_key] = new Cache_Eaccelerator($config);
                 break;
             case 'file':
                 $instances[$instance_key] = new Cache_File($config);
                 break;
             case 'file_generic':
                 $instances[$instance_key] = new Cache_File_Generic($config);
                 break;
             case 'memcached':
                 if (class_exists('\\Memcached')) {
                     $instances[$instance_key] = new Cache_Memcached($config);
                 } else {
                     if (class_exists('\\Memcache')) {
                         $instances[$instance_key] = new Cache_Memcache($config);
                     }
                 }
                 break;
             case 'redis':
                 $instances[$instance_key] = new Cache_Redis($config);
                 break;
             case 'wincache':
                 $instances[$instance_key] = new Cache_Wincache($config);
                 break;
             case 'xcache':
                 $instances[$instance_key] = new Cache_Xcache($config);
                 break;
             default:
                 trigger_error('Incorrect cache engine ' . $engine, E_USER_WARNING);
                 $instances[$instance_key] = new Cache_Base($config);
                 break;
         }
         if (!isset($instances[$instance_key]) || !$instances[$instance_key]->available()) {
             $instances[$instance_key] = new Cache_Base($config);
         }
     }
     return $instances[$instance_key];
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:64,代码来源:Cache.php

示例4: config_state

 public static function config_state()
 {
     if (Util_Environment::blog_id() <= 0) {
         return self::config_state_master();
     }
     static $config_state = null;
     if (is_null($config_state)) {
         $config_state = new ConfigState(false);
     }
     return $config_state;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:11,代码来源:Dispatcher.php

示例5: __construct

 public function __construct($blog_id = null)
 {
     if (!is_null($blog_id)) {
         $this->_blog_id = $blog_id;
         $this->_is_master = $this->_blog_id == 0;
     } else {
         if (Util_Environment::is_using_master_config()) {
             $this->_blog_id = 0;
         } else {
             $this->_blog_id = Util_Environment::blog_id();
         }
         $this->_is_master = Util_Environment::blog_id() == 0;
     }
     $this->_preview = Util_Environment::is_preview_mode();
     $this->load();
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:16,代码来源:Config.php

示例6: cleanup_local

 function cleanup_local()
 {
     $engine = $this->_config->get_string('pgcache.engine');
     switch ($engine) {
         case 'file':
             $w3_cache_file_cleaner = new Cache_File_Cleaner(array('cache_dir' => Util_Environment::cache_blog_dir('page'), 'clean_timelimit' => $this->_config->get_integer('timelimit.cache_gc')));
             $w3_cache_file_cleaner->clean();
             break;
         case 'file_generic':
             if (Util_Environment::blog_id() == 0) {
                 $flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR;
             } else {
                 $flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . Util_Environment::host();
             }
             $w3_cache_file_cleaner_generic = new Cache_File_Cleaner_Generic(array('exclude' => array('.htaccess'), 'cache_dir' => $flush_dir, 'expire' => $this->_config->get_integer('browsercache.html.lifetime'), 'clean_timelimit' => $this->_config->get_integer('timelimit.cache_gc')));
             $w3_cache_file_cleaner_generic->clean();
             break;
     }
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:19,代码来源:PgCache_Plugin_Admin.php

示例7: _get_cache

 /**
  * Returns minify cache object
  *
  * @return object
  */
 function _get_cache()
 {
     static $cache = array();
     if (!isset($cache[0])) {
         switch ($this->_config->get_string('minify.engine')) {
             case 'memcached':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify', 'servers' => $this->_config->get_array('minify.memcached.servers'), 'persistent' => $this->_config->get_boolean('minify.memcached.persistent'), 'aws_autodiscovery' => $this->_config->get_boolean('minify.memcached.aws_autodiscovery'), 'username' => $this->_config->get_boolean('minify.memcached.username'), 'password' => $this->_config->get_boolean('minify.memcached.password'));
                 if (class_exists('Memcached')) {
                     $w3_cache = new Cache_Memcached($config);
                 } else {
                     if (class_exists('Memcache')) {
                         $w3_cache = new Cache_Memcache($config);
                     }
                 }
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'redis':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify', 'servers' => $this->_config->get_array('minify.redis.servers'), 'persistent' => $this->_config->get_boolean('minify.redis.persistent'), 'dbid' => $this->_config->get_boolean('minify.redis.dbid'), 'password' => $this->_config->get_boolean('minify.redis.password'));
                 if (class_exists('Memcached')) {
                     $w3_cache = new Cache_Memcached($config);
                 } else {
                     if (class_exists('Memcache')) {
                         $w3_cache = new Cache_Memcache($config);
                     }
                 }
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'apc':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify');
                 if (function_exists('apcu_store')) {
                     $w3_cache = new Cache_Apcu($config);
                 } else {
                     if (function_exists('apc_store')) {
                         $w3_cache = new Cache_Apc($config);
                     }
                 }
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'eaccelerator':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify');
                 $w3_cache = new Cache_Eaccelerator($config);
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'xcache':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify');
                 $w3_cache = new Cache_Xcache($config);
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'wincache':
                 $config = array('blog_id' => Util_Environment::blog_id(), 'instance_id' => Util_Environment::instance_id(), 'host' => Util_Environment::host(), 'module' => 'minify');
                 $w3_cache = new Cache_Wincache($config);
                 $cache[0] = new \Minify_Cache_W3TCDerived($w3_cache);
                 break;
             case 'file':
             default:
                 $cache[0] = new \Minify_Cache_File(Util_Environment::cache_blog_minify_dir(), array('.htaccess', 'index.php', '*.old'), $this->_config->get_boolean('minify.file.locking'), $this->_config->get_integer('timelimit.cache_flush'), Util_Environment::blog_id() == 0 ? W3TC_CACHE_MINIFY_DIR : null);
                 break;
         }
     }
     return $cache[0];
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:66,代码来源:Minify_MinifiedFileRequestHandler.php

示例8: docroot_filename_to_uri

 /**
  * Convert relative file which is relative to ABSPATH (wp folder on disc) to path uri
  *
  * @param unknown $file
  * @return string
  */
 function docroot_filename_to_uri($file)
 {
     $file = ltrim($file, '/');
     // Translate multisite subsite uploads paths
     $file = str_replace(basename(WP_CONTENT_DIR) . '/blogs.dir/' . Util_Environment::blog_id() . '/', '', $file);
     return $file;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:13,代码来源:Cdn_Core.php

示例9: get_server_info

 /**
  * Returns server info
  *
  * @return array
  */
 private function get_server_info()
 {
     global $wp_version, $wp_db_version, $wpdb;
     $wordpress_plugins = get_plugins();
     $wordpress_plugins_active = array();
     foreach ($wordpress_plugins as $wordpress_plugin_file => $wordpress_plugin) {
         if (is_plugin_active($wordpress_plugin_file)) {
             $wordpress_plugins_active[$wordpress_plugin_file] = $wordpress_plugin;
         }
     }
     $mysql_version = $wpdb->get_var('SELECT VERSION()');
     $mysql_variables_result = (array) $wpdb->get_results('SHOW VARIABLES', ARRAY_N);
     $mysql_variables = array();
     foreach ($mysql_variables_result as $mysql_variables_row) {
         $mysql_variables[$mysql_variables_row[0]] = $mysql_variables_row[1];
     }
     $server_info = array('w3tc' => array('version' => W3TC_VERSION, 'server' => !empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown', 'dir' => W3TC_DIR, 'cache_dir' => W3TC_CACHE_DIR, 'blog_id' => Util_Environment::blog_id(), 'home_domain_root_url' => Util_Environment::home_domain_root_url(), 'home_url_maybe_https' => Util_Environment::home_url_maybe_https(), 'site_path' => Util_Environment::site_path(), 'document_root' => Util_Environment::document_root(), 'site_root' => Util_Environment::site_root(), 'site_url_uri' => Util_Environment::site_url_uri(), 'home_url_host' => Util_Environment::home_url_host(), 'home_url_uri' => Util_Environment::home_url_uri(), 'network_home_url_uri' => Util_Environment::network_home_url_uri(), 'host_port' => Util_Environment::host_port(), 'host' => Util_Environment::host(), 'wp_config_path' => Util_Environment::wp_config_path()), 'wp' => array('version' => $wp_version, 'db_version' => $wp_db_version, 'abspath' => ABSPATH, 'home' => get_option('home'), 'siteurl' => get_option('siteurl'), 'email' => get_option('admin_email'), 'upload_info' => (array) Util_Http::upload_info(), 'theme' => Util_Theme::get_current_theme(), 'wp_cache' => defined('WP_CACHE') && WP_CACHE ? 'true' : 'false', 'plugins' => $wordpress_plugins_active), 'mysql' => array('version' => $mysql_version, 'variables' => $mysql_variables));
     return $server_info;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:24,代码来源:Support_AdminActions.php

示例10: __construct

 /**
  * PHP5 style constructor
  */
 function __construct()
 {
     global $_wp_using_ext_object_cache;
     $this->_config = Dispatcher::config();
     $this->_lifetime = $this->_config->get_integer(array('fragmentcache', 'lifetime'));
     $this->_debug = $this->_config->get_boolean(array('fragmentcache', 'debug'));
     $this->_caching = $_wp_using_ext_object_cache = $this->_can_cache();
     $this->_blog_id = Util_Environment::blog_id();
     $this->_core = Dispatcher::component('Extension_FragmentCache_Core');
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:13,代码来源:Extension_FragmentCache_WpObjectCache.php

示例11: get_files_custom

 /**
  * Exports custom files to CDN
  *
  * @return array
  */
 function get_files_custom()
 {
     $files = array();
     $document_root = Util_Environment::document_root();
     $custom_files = $this->_config->get_array('cdn.custom.files');
     $custom_files = array_map(array('\\W3TC\\Util_Environment', 'parse_path'), $custom_files);
     $site_root = Util_Environment::site_root();
     $path = Util_Environment::site_url_uri();
     $site_root_dir = str_replace($document_root, '', $site_root);
     if (strstr(WP_CONTENT_DIR, Util_Environment::site_root()) === false) {
         $site_root = Util_Environment::document_root();
         $path = '';
     }
     $content_path = trim(str_replace(WP_CONTENT_DIR, '', $site_root), '/\\');
     foreach ($custom_files as $custom_file) {
         if ($custom_file != '') {
             $custom_file = Cdn_Util::replace_folder_placeholders($custom_file);
             $custom_file = Util_Environment::normalize_file($custom_file);
             if (!Util_Environment::is_wpmu()) {
                 $dir = trim(dirname($custom_file), '/\\');
                 $rel_path = trim(dirname($custom_file), '/\\');
             } else {
                 $rel_path = $dir = trim(dirname($custom_file), '/\\');
             }
             if (strpos($dir, '<currentblog>') != false) {
                 $rel_path = $dir = str_replace('<currentblog>', 'blogs.dir/' . Util_Environment::blog_id(), $dir);
             }
             if ($dir == '.') {
                 $rel_path = $dir = '';
             }
             $mask = basename($custom_file);
             $files = array_merge($files, Cdn_Util::search_files($document_root . '/' . $dir, $rel_path, $mask));
         }
     }
     return $files;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:41,代码来源:Cdn_Plugin.php

示例12: execute_delayed_operations

 /**
  * Sends messages stored in $messages
  *
  * @return boolean
  */
 public function execute_delayed_operations()
 {
     if (count($this->messages) <= 0) {
         return true;
     }
     $this->_log($this->_get_action() . ' sending messages');
     $message = array();
     $message['actions'] = $this->messages;
     $message['blog_id'] = Util_Environment::blog_id();
     $message['host'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
     $message['hostname'] = @gethostname();
     $v = json_encode($message);
     try {
         $api = $this->_get_api();
         if (defined('WP_CLI') && WP_CLI) {
             $origin = 'WP CLI';
         } else {
             $origin = 'WP';
         }
         $this->_log($origin . ' sending message ' . $v);
         $this->_log('Host: ' . $message['host']);
         if (isset($_SERVER['REQUEST_URI'])) {
             $this->_log('URL: ' . $_SERVER['REQUEST_URI']);
         }
         if (function_exists('current_filter')) {
             $this->_log('Current WP hook: ' . current_filter());
         }
         $backtrace = debug_backtrace();
         $backtrace_optimized = array();
         foreach ($backtrace as $b) {
             $opt = isset($b['function']) ? $b['function'] . ' ' : '';
             $opt .= isset($b['file']) ? $b['file'] . ' ' : '';
             $opt .= isset($b['line']) ? '#' . $b['line'] . ' ' : '';
             $backtrace_optimized[] = $opt;
         }
         $this->_log('Backtrace ', $backtrace_optimized);
         $r = $api->publish($this->_topic_arn, $v);
         if ($r->status != 200) {
             $this->_log("Error: {$r->body->Error->Message}");
             return false;
         }
     } catch (\Exception $e) {
         $this->_log('Error ' . $e->getMessage());
         return false;
     }
     // on success - reset messages array, but not hash (not resent repeatedly the same messages)
     $this->messages = array();
     return true;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:54,代码来源:Enterprise_CacheFlush_MakeSnsEvent.php

示例13: preview_production_copy

 /**
  * Deploys the config file from a preview config file
  *
  * @param integer $direction     +1: preview->production
  *                           -1: production->preview
  * @param boolean $remove_source remove source file
  */
 private function preview_production_copy($direction = 1)
 {
     $blog_id = Util_Environment::blog_id();
     $preview_filename = Config::util_config_filename($blog_id, true);
     $production_filename = Config::util_config_filename($blog_id, false);
     if ($direction > 0) {
         $src = $preview_filename;
         $dest = $production_filename;
     } else {
         $src = $production_filename;
         $dest = $preview_filename;
     }
     if (!@copy($src, $dest)) {
         Util_Activation::throw_on_write_error($dest);
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:23,代码来源:Generic_AdminActions_Config.php

示例14: parse_path

 /**
  * Parses path
  *
  * @param string  $path
  * @return mixed
  */
 public static function parse_path($path)
 {
     $path = str_replace(array('%BLOG_ID%', '%POST_ID%', '%BLOG_ID%', '%HOST%'), array(isset($GLOBALS['blog_id']) ? (int) $GLOBALS['blog_id'] : 0, isset($GLOBALS['post_id']) ? (int) $GLOBALS['post_id'] : 0, Util_Environment::blog_id(), Util_Environment::host()), $path);
     return $path;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:11,代码来源:Util_Environment.php

示例15: __construct

 /**
  * PHP5 style constructor
  */
 function __construct()
 {
     global $_wp_using_ext_object_cache;
     $this->_config = Dispatcher::config();
     $this->_lifetime = $this->_config->get_integer('objectcache.lifetime');
     $this->_debug = $this->_config->get_boolean('objectcache.debug');
     $this->_caching = $_wp_using_ext_object_cache = $this->_can_cache();
     $this->global_groups = $this->_config->get_array('objectcache.groups.global');
     $this->nonpersistent_groups = $this->_config->get_array('objectcache.groups.nonpersistent');
     $this->_blog_id = Util_Environment::blog_id();
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:14,代码来源:ObjectCache_WpObjectCache_Regular.php


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