/** * Creates add-in * * @throws Util_WpFile_FilesystemOperationException */ private function create_addin() { $src = W3TC_INSTALL_FILE_DB; $dst = W3TC_ADDIN_FILE_DB; if ($this->db_installed()) { if ($this->is_dbcache_add_in()) { $script_data = @file_get_contents($dst); if ($script_data == @file_get_contents($src)) { return; } } else { if (get_transient('w3tc_remove_add_in_dbcache') == 'yes') { // user already manually asked to remove another plugin's add in, // we should try to apply ours // (in case of missing permissions deletion could fail) } else { if (!$this->db_check_old_add_in()) { if (isset($_GET['page'])) { $url = 'admin.php?page=' . $_GET['page'] . '&'; } else { $url = basename(Util_Environment::remove_query($_SERVER['REQUEST_URI'])) . '?page=w3tc_dashboard&'; } $remove_url = Util_Ui::admin_url($url . 'w3tc_default_remove_add_in=dbcache'); throw new Util_WpFile_FilesystemOperationException(sprintf(__('The Database add-in file db.php is not a W3 Total Cache drop-in. Remove it or disable Database Caching. %s', 'w3-total-cache'), Util_Ui::button_link(__('Remove it for me', 'w3-total-cache'), wp_nonce_url($remove_url, 'w3tc')))); } } } } Util_WpFile::copy_file($src, $dst); }
function _url_has_to_be_replaced($url, $extension) { static $extensions = null; if ($extensions === null) { $core = Dispatcher::component('BrowserCache_Core'); $extensions = $core->get_replace_extensions($this->_config); } static $exceptions = null; if ($exceptions === null) { $exceptions = $this->_config->get_array('browsercache.replace.exceptions'); } if (!in_array($extension, $extensions)) { return false; } $test_url = Util_Environment::remove_query($url); foreach ($exceptions as $exception) { if (trim($exception) && preg_match('~' . $exception . '~', $test_url)) { return false; } } return true; }