/** * 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 w3tc_default_remove_add_in() { $module = Util_Request::get_string('w3tc_default_remove_add_in'); // in the case of missing permissions to delete // environment will use that to try to override addin via ftp set_transient('w3tc_remove_add_in_' . $module, 'yes', 600); switch ($module) { case 'pgcache': Util_WpFile::delete_file(W3TC_ADDIN_FILE_ADVANCED_CACHE); $src = W3TC_INSTALL_FILE_ADVANCED_CACHE; $dst = W3TC_ADDIN_FILE_ADVANCED_CACHE; try { Util_WpFile::copy_file($src, $dst); } catch (Util_WpFile_FilesystemOperationException $ex) { } break; case 'dbcache': Util_WpFile::delete_file(W3TC_ADDIN_FILE_DB); break; case 'objectcache': Util_WpFile::delete_file(W3TC_ADDIN_FILE_OBJECT_CACHE); break; } Util_Admin::redirect(array('w3tc_note' => 'add_in_removed'), true); }
/** * Checks if addins in wp-content is available and correct version. * * @param unknown $config * @param Util_Environment_Exceptions $exs */ private function create_required_files($config, $exs) { $src = W3TC_INSTALL_FILE_ADVANCED_CACHE; $dst = W3TC_ADDIN_FILE_ADVANCED_CACHE; if ($this->advanced_cache_installed()) { if ($this->is_advanced_cache_add_in()) { $script_data = @file_get_contents($dst); if ($script_data == @file_get_contents($src)) { return; } } else { if (get_transient('w3tc_remove_add_in_pgcache') == '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->advanced_cache_check_old_add_in()) { $remove_url = Util_Ui::admin_url('admin.php?page=w3tc_dashboard&w3tc_default_remove_add_in=pgcache'); $exs->push(new Util_WpFile_FilesystemOperationException(sprintf(__('The Page Cache add-in file advanced-cache.php is not a W3 Total Cache drop-in. It should be removed. %s', 'w3-total-cache'), Util_Ui::button_link(__('Yes, remove it for me', 'w3-total-cache'), wp_nonce_url($remove_url, 'w3tc'))))); return; } } } } try { Util_WpFile::copy_file($src, $dst); } catch (Util_WpFile_FilesystemOperationException $ex) { $exs->push($ex); } }