本文整理汇总了PHP中Util_Environment::cache_blog_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::cache_blog_dir方法的具体用法?PHP Util_Environment::cache_blog_dir怎么用?PHP Util_Environment::cache_blog_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::cache_blog_dir方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param array $config
*/
function __construct($config = array())
{
parent::__construct($config);
if (isset($config['cache_dir'])) {
$this->_cache_dir = trim($config['cache_dir']);
} else {
$this->_cache_dir = Util_Environment::cache_blog_dir($config['section'], $config['blog_id']);
}
$this->_exclude = isset($config['exclude']) ? (array) $config['exclude'] : array();
$this->_flush_timelimit = isset($config['flush_timelimit']) ? (int) $config['flush_timelimit'] : 180;
$this->_locking = isset($config['locking']) ? (bool) $config['locking'] : false;
if (isset($config['flush_dir'])) {
$this->_flush_dir = $config['flush_dir'];
} else {
if ($config['blog_id'] <= 0 && !isset($config['cache_dir'])) {
// clear whole section if we operate on master cache
// and in a mode when cache_dir not strictly specified
$this->_flush_dir = Util_Environment::cache_dir($config['section']);
} else {
$this->_flush_dir = $this->_cache_dir;
}
}
if (isset($config['use_wp_hash']) && $config['use_wp_hash']) {
$this->_use_wp_hash = true;
}
}
示例2: cleanup
function cleanup()
{
$c = Dispatcher::config();
$engine = $c->get_string(array('fragmentcache', 'engine'));
switch ($engine) {
case 'file':
$w3_cache_file_cleaner = new Cache_File_Cleaner(array('cache_dir' => Util_Environment::cache_blog_dir('fragment'), 'clean_timelimit' => $c->get_integer('timelimit.cache_gc')));
$w3_cache_file_cleaner->clean();
break;
}
}
示例3: 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;
}
}
示例4: _precache_file
/**
* Pre-caches external file
*
* @param string $url
* @param string $type
* @return string
*/
function _precache_file($url, $type)
{
$lifetime = $this->_config->get_integer('minify.lifetime');
$cache_path = sprintf('%s/minify_%s.%s', Util_Environment::cache_blog_dir('minify'), md5($url), $type);
if (!file_exists($cache_path) || @filemtime($cache_path) < time() - $lifetime) {
if (!@is_dir(dirname($cache_path))) {
Util_File::mkdir_from(dirname($cache_path), W3TC_CACHE_DIR);
}
Util_Http::download($url, $cache_path);
}
return file_exists($cache_path) ? $this->_get_minify_source($cache_path, $url) : false;
}
示例5: cleanup
/**
* Does disk cache cleanup
*
* @return void
*/
function cleanup()
{
$w3_cache_file_cleaner_generic = new Cache_File_Cleaner_Generic(array('exclude' => array('*.files', '.htaccess', 'index.php'), 'cache_dir' => Util_Environment::cache_blog_dir('minify'), 'expire' => $this->_config->get_integer('minify.file.gc'), 'clean_timelimit' => $this->_config->get_integer('timelimit.cache_gc')));
$w3_cache_file_cleaner_generic->clean();
}
示例6: cleanup
/**
* Does disk cache cleanup
*
* @return void
*/
function cleanup()
{
$w3_cache_file_cleaner = new Cache_File_Cleaner(array('cache_dir' => Util_Environment::cache_blog_dir('db'), 'clean_timelimit' => $this->_config->get_integer('timelimit.cache_gc')));
$w3_cache_file_cleaner->clean();
}
示例7: get_files_minify
/**
* Exports min files to CDN
*
* @return array
*/
function get_files_minify()
{
$files = array();
if ($this->_config->get_boolean('minify.rewrite') && Util_Rule::can_check_rules() && (!$this->_config->get_boolean('minify.auto') || Cdn_Util::is_engine_mirror($this->_config->get_string('cdn.engine')))) {
$minify = Dispatcher::component('Minify_Plugin');
$document_root = Util_Environment::document_root();
$minify_root = Util_Environment::cache_blog_dir('minify');
$minify_path = ltrim(str_replace($document_root, '', $minify_root), '/');
$urls = $minify->get_urls();
// in WPMU + network admin (this code used for minify manual only)
// common minify files are stored under context of main blog (i.e. 1)
// but have urls of 0 blog, so download has to be used
if ($this->_config->get_string('minify.engine') == 'file' && !(Util_Environment::is_wpmu() && is_network_admin())) {
foreach ($urls as $url) {
Util_Http::get($url);
}
$files = Cdn_Util::search_files($minify_root, $minify_path, '*.css;*.js');
} else {
foreach ($urls as $url) {
$file = Util_Environment::normalize_file_minify($url);
$file = Util_Environment::translate_file($file);
if (!Util_Environment::is_url($file)) {
$file = $document_root . '/' . $file;
$file = ltrim(str_replace($minify_root, '', $file), '/');
$dir = dirname($file);
if ($dir) {
Util_File::mkdir($dir, 0777, $minify_root);
}
if (Util_Http::download($url, $minify_root . '/' . $file) !== false) {
$files[] = $minify_path . '/' . $file;
}
}
}
}
}
return $files;
}
示例8: cache_blog_minify_dir
public static function cache_blog_minify_dir()
{
// when minify manual used with a shared config - shared
// minify urls has to be used too, since CDN upload is possible
// only from network admin
if (Util_Environment::is_wpmu() && Util_Environment::is_using_master_config() && !Dispatcher::config()->get_boolean('minify.auto')) {
$path = Util_Environment::cache_blog_dir('minify', 0);
} else {
$path = Util_Environment::cache_blog_dir('minify');
}
return $path;
}
示例9: on_cdn_file_upload
/**
* Called on successful file upload to CDN
*
* @param unknown $file_name
*/
public static function on_cdn_file_upload($file_name)
{
$minify_enabled = self::config()->get_boolean('minify.enabled');
if ($minify_enabled) {
$minify_document_root = Util_Environment::cache_blog_dir('minify') . '/';
if (!substr($file_name, 0, strlen($minify_document_root)) == $minify_document_root) {
// unexpected file name
return;
}
$short_file_name = substr($file_name, strlen($minify_document_root));
$minify = Dispatcher::component('Minify_MinifiedFileRequestHandler');
$minify->set_file_custom_data($short_file_name, array('cdn.status' => 'uploaded'));
}
}