本文整理汇总了PHP中w3_get_blog_id函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_blog_id函数的具体用法?PHP w3_get_blog_id怎么用?PHP w3_get_blog_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_blog_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fix_in_wpadmin
function fix_in_wpadmin($config, $force_all_checks = false)
{
$exs = new SelfTestExceptions();
$fix_on_event = false;
if (w3_is_multisite() && w3_get_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 (SelfTestExceptions $ex) {
$exs->push($ex);
}
}
if (count($exs->exceptions()) > 0) {
throw $exs;
}
}
示例2: get_wordpress_appname
/**
* @param W3_Config $config
* @param W3_Config $config_master
* @param bool $do_merge if to merge with network main site
* @return string
*/
public static function get_wordpress_appname($config, $config_master, $do_merge = true)
{
if (w3_is_network()) {
if ($config_master->get_boolean('newrelic.use_network_wide_id')) {
$appname = $config_master->get_string('newrelic.appname');
} else {
$merge = $config->get_boolean('newrelic.merge_with_network');
$merge_name = '';
if ($do_merge && $merge && w3_get_blog_id() != 0) {
$merge_name = ';' . $config_master->get_string('newrelic.appname');
}
if (w3_get_blog_id() != 0 && !$config->get_boolean('common.force_master')) {
$appname = $config->get_string('newrelic.appname', '');
if (empty($appname)) {
$prefix = $config->get_string('newrelic.appname_prefix');
$appname = $prefix . trim(w3_get_home_domain() . w3_get_site_path(), '/');
}
} else {
if (w3_get_blog_id() != 0) {
$prefix = $config->get_string('newrelic.appname_prefix');
$appname = $prefix . trim(w3_get_home_domain() . w3_get_site_path(), '/');
} else {
$appname = $config->get_string('newrelic.appname');
}
}
$appname = $appname . $merge_name;
}
} else {
$appname = $config->get_string('newrelic.appname');
}
return $appname;
}
示例3: __construct
/**
* Constructor
*/
function __construct()
{
$this->_blog_id = w3_get_blog_id();
// defines $keys_admin with descriptors
include W3TC_LIB_W3_DIR . '/ConfigKeys.php';
$this->_keys = $keys_admin;
$this->_aggregated_data_object = new W3_ConfigData($keys_admin);
$this->_aggregated_data_object->set_defaults();
// load master-config data
$filename1 = $this->_get_config_filename(true);
$this->_aggregated_data_object->read($filename1);
// load blog-config data (or master if we are master)
$filename2 = $this->_get_config_filename();
$this->_data_object = new W3_ConfigData($keys_admin);
// set defaults
$this->_data_object->set_group($this->_aggregated_data_object->data);
$data = W3_ConfigData::get_array_from_file($filename2);
if (!is_null($data)) {
foreach ($data as $key => $value) {
if ($this->_writable_key($key)) {
$this->_data_object->set($key, $value);
}
}
}
// merge blog-specific config data to aggregated data
if ($this->_blog_id > 0) {
$this->_aggregated_data_object->set_group($this->_data_object->data);
}
$this->_data =& $this->_aggregated_data_object->data;
}
示例4: w3_run_legacy_update
/**
* Updates the plugin from older version.
*/
function w3_run_legacy_update()
{
w3_require_once(W3TC_LIB_W3_DIR . '/ConfigWriter.php');
$writer = new W3_ConfigWriter(w3_get_blog_id(), w3_is_preview_mode());
$writer->import_legacy_config_and_save();
// Only remove folders when master blog is running.
if (w3_get_blog_id() == 0) {
w3_remove_old_folders();
}
}
示例5: 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'] = w3_get_blog_id();
}
$instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
if (!isset($instances[$instance_key])) {
switch ($engine) {
case W3TC_CACHE_MEMCACHED:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Memcached.php');
$instances[$instance_key] = new W3_Cache_Memcached($config);
break;
case W3TC_CACHE_APC:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Apc.php');
$instances[$instance_key] = new W3_Cache_Apc($config);
break;
case W3TC_CACHE_EACCELERATOR:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Eaccelerator.php');
$instances[$instance_key] = new W3_Cache_Eaccelerator($config);
break;
case W3TC_CACHE_XCACHE:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Xcache.php');
$instances[$instance_key] = new W3_Cache_Xcache($config);
break;
case W3TC_CACHE_WINCACHE:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Wincache.php');
$instances[$instance_key] = new W3_Cache_Wincache($config);
break;
case W3TC_CACHE_FILE:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/File.php');
$instances[$instance_key] = new W3_Cache_File($config);
break;
case W3TC_CACHE_FILE_GENERIC:
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/File/Generic.php');
$instances[$instance_key] = new W3_Cache_File_Generic($config);
break;
default:
trigger_error('Incorrect cache engine', E_USER_WARNING);
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Base.php');
$instances[$instance_key] = new W3_Cache_Base($config);
break;
}
if (!$instances[$instance_key]->available()) {
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Base.php');
$instances[$instance_key] = new W3_Cache_Base($config);
}
}
return $instances[$instance_key];
}
示例6: __construct
/**
* Constructor
*/
function __construct($master = false)
{
$preview = w3_is_preview_mode();
if (defined('WP_ADMIN')) {
$config_admin = w3_instance('W3_ConfigAdmin');
$preview = $config_admin->get_boolean('previewmode.enabled');
}
if ($master) {
$this->_blog_id = 0;
} else {
$this->_blog_id = w3_get_blog_id();
}
$this->_preview = $preview;
$this->load();
}
示例7: change_filename_length
function change_filename_length()
{
try {
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$new = W3_Request::get_integer('maxlength');
$this->_config->set('minify.auto.filename_length', $new);
set_transient('w3tc_minify_tested_filename_length', true, 3600 * 24);
$this->_config->save();
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php');
$cache = new Minify_Cache_File(w3_cache_blog_dir('minify'), array('.htaccess', 'index.php', '*.old'), $this->_config->get_boolean('minify.file.locking'), $this->_config->get_integer('timelimit.cache_flush'), w3_get_blog_id() == 0 ? W3TC_CACHE_MINIFY_DIR : null);
$cache->flush();
echo 1;
} catch (Exception $ex) {
echo $ex->getMessage();
}
exit;
}
示例8: cleanup_local
function cleanup_local()
{
$engine = $this->_config->get_string('pgcache.engine');
switch ($engine) {
case 'file':
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/File/Cleaner.php');
$w3_cache_file_cleaner = new W3_Cache_File_Cleaner(array('cache_dir' => w3_cache_blog_dir('page'), 'clean_timelimit' => $this->_config->get_integer('timelimit.cache_gc')));
$w3_cache_file_cleaner->clean();
break;
case 'file_generic':
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/File/Cleaner/Generic.php');
if (w3_get_blog_id() == 0) {
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR;
} else {
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . w3_get_domain(w3_get_host());
}
$w3_cache_file_cleaner_generic = new W3_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;
}
}
示例9: admin_notices
function admin_notices()
{
/**
* @var $nerser W3_NewRelicService
*/
$nerser = w3_instance('W3_NewRelicService');
$new_relic_configured = $this->_config->get_string('newrelic.account_id') && $this->_config->get_string('newrelic.api_key');
if (w3_get_blog_id() == 0 || !$this->_config->get_boolean('common.force_master')) {
$new_relic_configured = $new_relic_configured && $this->_config->get_string('newrelic.application_id');
}
$verify_running_result = $nerser->verify_running();
$not_running = is_array($verify_running_result);
if ($not_running) {
$message = '<p>' . __('New Relic is not running correctly. The plugin has detected the following issues:', 'w3-total-cache') . "</p>\n";
$message .= "<ul class=\"w3-bullet-list\">\n";
foreach ($verify_running_result as $cause) {
$message .= "<li>{$cause}</li>";
}
$message .= "</ul>\n";
$message .= "<p>" . sprintf(__('Please review the <a href="%s">settings</a>.', 'w3-total-cache'), network_admin_url('admin.php?page=w3tc_general#monitoring')) . "</p>";
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
w3_e_error_box($message);
}
}
示例10: _get_page_key
/**
* Returns page key
*
* @param string $request_uri
* @param string $compression
* @return string
*/
function _get_page_key($request_uri, $compression)
{
if ($this->_config->get_string('pgcache.engine') == 'file_pgcache') {
$request_uri = preg_replace('~\\?.*$~', '', $request_uri);
$request_uri = str_replace('/index.php', '/', $request_uri);
$request_uri = preg_replace('~[/\\\\]+~', '/', $request_uri);
$request_uri = w3_realpath($request_uri);
if (empty($request_uri)) {
$request_uri = '/';
}
if (substr($request_uri, -1) == '/') {
$request_uri .= 'index.html';
}
$request_uri = ltrim($request_uri, '/');
$key = sprintf('%s/%s', $_SERVER['HTTP_HOST'], $request_uri);
if (!empty($compression)) {
$key .= '.' . $compression;
}
} else {
$blog_id = w3_get_blog_id();
if (empty($blog_id)) {
$blog_id = $_SERVER['HTTP_HOST'];
}
$key = sprintf('w3tc_%s_page_%s', md5($blog_id), md5($request_uri));
if (!empty($compression)) {
$key .= '_' . $compression;
}
}
return $key;
}
示例11: __construct
/**
* PHP5 style constructor
*/
function __construct()
{
global $_wp_using_ext_object_cache;
$this->_config = w3_instance('W3_Config');
$this->_lifetime = $this->_config->get_integer('fragmentcache.lifetime');
$this->_debug = $this->_config->get_boolean('fragmentcache.debug');
$this->_caching = $_wp_using_ext_object_cache = $this->_can_cache();
$this->_blog_id = w3_get_blog_id();
$this->_fragmentcache = w3_instance('W3_Pro_Plugin_FragmentCache');
}
示例12: _get_cache
/**
* Returns cache object
*
* @return W3_Cache_Base
*/
function _get_cache()
{
static $cache = array();
if (!isset($cache[0])) {
$engine = $this->_config->get_string('pgcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('pgcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('pgcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('section' => 'page', 'flush_parent' => w3_get_blog_id() == 0, 'locking' => $this->_config->get_boolean('pgcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
case 'file_generic':
if (w3_get_blog_id() == 0) {
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR;
} else {
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . w3_get_domain(w3_get_host());
}
$engineConfig = array('exclude' => array('.htaccess'), 'expire' => $this->_lifetime, 'cache_dir' => W3TC_CACHE_PAGE_ENHANCED_DIR, 'locking' => $this->_config->get_boolean('pgcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'), 'flush_dir' => $flush_dir);
break;
default:
$engineConfig = array();
}
$engineConfig['use_expired_data'] = true;
$engineConfig['module'] = 'pgcache';
$engineConfig['host'] = w3_get_host();
$engineConfig['instance_id'] = w3_get_instance_id();
w3_require_once(W3TC_LIB_W3_DIR . '/Cache.php');
$cache[0] = W3_Cache::instance($engine, $engineConfig);
}
return $cache[0];
}
示例13: checked
<td>
<input name="newrelic.include_rum" type="hidden" value="0" />
<input id="newrelic_include_rum" name="newrelic.include_rum" type="checkbox" value="1" <?php
checked($this->_config->get_boolean('newrelic.include_rum'));
?>
/>
<p><span class="description">
<?php
_e('This enables inclusion of <acronym title="Real User Monitoring">RUM</acronym> when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced', 'w3-total-cache');
?>
</span>
</p>
</td>
</tr>
<?php
if (w3_is_network() && w3_get_blog_id() == 0) {
?>
<tr>
<th><label for="newrelic_appname_prefix"><?php
_e('Prefix network sites:', 'w3-total-cache');
?>
</label></th>
<td><input id="newrelic_appname_prefix" name="newrelic.appname_prefix" type="text" value="<?php
echo esc_attr($this->_config->get_string('newrelic.appname_prefix'));
?>
" /></td>
</tr>
<tr>
<th><label for="newrelic_merge_with_network"><?php
_e('Include network sites stats in network:', 'w3-total-cache');
?>
示例14: _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':
w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Memcached.php');
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Memcache.php');
$w3_cache_memcached = new W3_Cache_Memcached(array('blog_id' => w3_get_blog_id(), 'instance_id' => w3_get_instance_id(), 'host' => w3_get_host(), 'module' => 'minify', 'servers' => $this->_config->get_array('minify.memcached.servers'), 'persistant' => $this->_config->get_boolean('minify.memcached.persistant')));
$cache[0] = new Minify_Cache_Memcache($w3_cache_memcached, 0, w3_get_blog_id(), w3_get_instance_id());
break;
case 'apc':
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/APC.php');
$cache[0] = new Minify_Cache_APC(0, w3_get_blog_id(), w3_get_instance_id());
break;
case 'eaccelerator':
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Eaccelerator.php');
$cache[0] = new Minify_Cache_Eaccelerator(0, w3_get_blog_id(), w3_get_instance_id());
break;
case 'xcache':
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/XCache.php');
$cache[0] = new Minify_Cache_XCache(0, w3_get_blog_id(), w3_get_instance_id());
break;
case 'wincache':
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Wincache.php');
$cache[0] = new Minify_Cache_Wincache(0, w3_get_blog_id(), w3_get_instance_id());
break;
case 'file':
default:
w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php');
$cache[0] = new Minify_Cache_File(w3_cache_blog_dir('minify'), array('.htaccess', 'index.php', '*.old'), $this->_config->get_boolean('minify.file.locking'), $this->_config->get_integer('timelimit.cache_flush'), w3_get_blog_id() == 0 ? W3TC_CACHE_MINIFY_DIR : null);
break;
}
}
return $cache[0];
}
示例15: after_config_change
/**
* Called from admin interface after configuration is changed
*/
function after_config_change()
{
$this->schedule();
if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_boolean('minify.rewrite')) {
if (w3_can_modify_rules(w3_get_minify_rules_core_path())) {
$this->write_rules_core();
}
if ($this->_config->get_string('minify.engine') == 'file') {
if (w3_can_modify_rules(w3_get_minify_rules_cache_path())) {
try {
$this->write_rules_cache();
} catch (Exception $e) {
}
}
} else {
if (w3_can_modify_rules(w3_get_minify_rules_cache_path()) && w3_get_blog_id() == 0) {
$this->remove_rules_cache();
}
}
} else {
if (w3_can_modify_rules(w3_get_minify_rules_core_path()) && w3_get_blog_id() == 0) {
$this->remove_rules_core();
}
if (w3_can_modify_rules(w3_get_minify_rules_cache_path()) && w3_get_blog_id() == 0) {
$this->remove_rules_cache();
}
}
}