/** * Returns required rules for module * * @param Config $config * @return array */ public function get_required_rules($config) { if (!$config->get_boolean('browsercache.enabled')) { return null; } $rewrite_rules = array(); if (Dispatcher::should_browsercache_generate_rules_for_cdn($config)) { $domain = Dispatcher::get_cdn_domain(); $cdn_rules_path = sprintf('ftp://%s/%s', $domain, Util_Rule::get_cdn_rules_path()); $rewrite_rules[] = array('filename' => $cdn_rules_path, 'content' => $this->rules_cache_generate($config, true)); } $browsercache_rules_cache_path = Util_Rule::get_browsercache_rules_cache_path(); $rewrite_rules[] = array('filename' => $browsercache_rules_cache_path, 'content' => $this->rules_cache_generate($config)); if ($config->get_boolean('browsercache.no404wp')) { $browsercache_rules_no404wp_path = Util_Rule::get_browsercache_rules_no404wp_path(); $rewrite_rules[] = array('filename' => $browsercache_rules_no404wp_path, 'content' => $this->rules_no404wp_generate($config)); } return $rewrite_rules; }
/** * Deletes Browser Cache .htaccess from FTP * * @return void */ public static function cdn_delete_browsercache() { $common = Dispatcher::component('Cdn_Core'); $cdn_path = Util_Rule::get_cdn_rules_path(); $tmp_path = W3TC_CACHE_TMP_DIR . '/' . $cdn_path; $results = array(); $delete = array($common->build_file_descriptor($tmp_path, $cdn_path)); $common->delete($delete, false, $results); }
/** * Returns required rules for module * * @param Config $config * @return array|null */ function get_required_rules($config) { if (!$config->get_boolean('cdn.enabled')) { return null; } $rewrite_rules = array(); $rules = $this->rules_generate($config); if (strlen($rules) > 0) { if ($config->get_string('cdn.engine') == 'ftp') { $common = Dispatcher::component('Cdn_Core'); $domain = $common->get_cdn()->get_domain(); $cdn_rules_path = sprintf('ftp://%s/%s', $domain, Util_Rule::get_cdn_rules_path()); $rewrite_rules[] = array('filename' => $cdn_rules_path, 'content' => $rules); } $path = Util_Rule::get_browsercache_rules_cache_path(); $rewrite_rules[] = array('filename' => $path, 'content' => $rules); } return $rewrite_rules; }