/** * 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 = w3_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) { // clear whole section if we operate on master cache $this->_flush_dir = w3_cache_dir($config['section']); } else { $this->_flush_dir = $this->_cache_dir; } } if (isset($config['use_wp_hash']) && $config['use_wp_hash'] && function_exists('wp_hash')) { $this->_use_wp_hash = true; } }
/** * 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 $module * @param null $blog_id * @return string */ function w3_debug_log($module, $blog_id = null) { if (is_null($blog_id)) { $blog_id = w3_get_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 = w3_cache_dir('log'); } $filename = $dir_path . '/' . $postfix . '/' . $module . '.log'; if (!is_dir(dirname($filename))) { w3_require_once(W3TC_INC_DIR . '/functions/file.php'); w3_mkdir_from(dirname($filename), $from_dir); } return $filename; }