private function delete_files_and_folders() { $ftp_form = null; $errors = array(); $dirs = array(W3TC_CACHE_DIR); $files = array(W3TC_ADDIN_FILE_DB, W3TC_ADDIN_FILE_OBJECT_CACHE, W3TC_ADDIN_FILE_ADVANCED_CACHE); if (file_exists(W3TC_WP_LOADER)) { $files[] = W3TC_WP_LOADER; } foreach ($files as $file) { try { w3_wp_delete_file($file); } catch (Exception $e) { if ($e instanceof FilesystemCredentialException) { $ftp_form = $e->ftp_form(); } } if (file_exists($file)) { $errors[] = sprintf('Delete file: <strong>%s</strong>', $file); } } try { @set_time_limit(60); w3_wp_delete_folders($dirs); } catch (Exception $e) { if ($e instanceof FilesystemCredentialException) { $ftp_form = $e->ftp_form(); } } foreach ($dirs as $folder) { if (@is_dir($folder)) { $errors[] = sprintf('Delete folder: <strong>%s</strong>', $folder); } } return array('errors' => $errors, 'ftp_form' => $ftp_form); }
/** * Admin notices action * * @return void */ function admin_notices() { $w3tc_error = array(); $pgcache_rules_cache_path = w3_get_pgcache_rules_cache_path(); $browsercache_rules_no404wp_path = w3_get_browsercache_rules_no404wp_path(); $cookie_domain = $this->get_cookie_domain(); $error_messages = array('fancy_permalinks_disabled_pgcache' => sprintf('Fancy permalinks are disabled. Please %s it first, then re-attempt to enabling enhanced disk mode.', $this->button_link('enable', 'options-permalink.php')), 'fancy_permalinks_disabled_browsercache' => sprintf('Fancy permalinks are disabled. Please %s it first, then re-attempt to enabling the \'Do not process 404 errors for static objects with WordPress\'.', $this->button_link('enable', 'options-permalink.php')), 'pgcache_remove_rules_wpsc' => sprintf('The WP Super Cache rules could not be removed. Please run <strong>chmod 777 %s</strong> to resolve this issue.', file_exists($pgcache_rules_cache_path) ? $pgcache_rules_cache_path : dirname($pgcache_rules_cache_path)), 'browsercache_write_rules_no404wp' => sprintf('The browser cache rules could not be modified. Please %srun <strong>chmod 777 %s</strong> to resolve this issue.', file_exists($browsercache_rules_no404wp_path) ? '' : sprintf('create an empty file in <strong>%s</strong> and ', $browsercache_rules_no404wp_path), $browsercache_rules_no404wp_path), 'browsercache_write_rules_cdn' => sprintf('The browser cache rules for <acronym title="Content Delivery Network">CDN</acronym> could not be modified. Please check <acronym title="Content Delivery Network">CDN</acronym> settings.'), 'support_request_type' => 'Please select request type.', 'support_request_url' => 'Please enter the address of the site in the site <acronym title="Uniform Resource Locator">URL</acronym> field.', 'support_request_name' => 'Please enter your name in the Name field', 'support_request_email' => 'Please enter valid email address in the E-Mail field.', 'support_request_phone' => 'Please enter your phone in the phone field.', 'support_request_subject' => 'Please enter subject in the subject field.', 'support_request_description' => 'Please describe the issue in the issue description field.', 'support_request_wp_login' => 'Please enter an administrator login. Create a temporary one just for this support case if needed.', 'support_request_wp_password' => 'Please enter WP Admin password, be sure it\'s spelled correctly.', 'support_request_ftp_host' => 'Please enter <acronym title="Secure Shell">SSH</acronym> or <acronym title="File Transfer Protocol">FTP</acronym> host for the site.', 'support_request_ftp_login' => 'Please enter <acronym title="Secure Shell">SSH</acronym> or <acronym title="File Transfer Protocol">FTP</acronym> login for the server. Create a temporary one just for this support case if needed.', 'support_request_ftp_password' => 'Please enter <acronym title="Secure Shell">SSH</acronym> or <acronym title="File Transfer Protocol">FTP</acronym> password for the <acronym title="File Transfer Protocol">FTP</acronym> account.', 'support_request' => 'Unable to send the support request.', 'config_import_no_file' => 'Please select config file.', 'config_import_upload' => 'Unable to upload config file.', 'config_import_import' => 'Configuration file could not be imported.', 'config_reset' => sprintf('Default settings could not be restored. Please run <strong>chmod 777 %s</strong> to make the configuration file write-able, then try again.', W3TC_CONFIG_DIR), 'cdn_purge_attachment' => 'Unable to purge attachment.', 'pgcache_purge_post' => 'Unable to purge post.', 'pgcache_purge_page' => 'Unable to purge page.', 'enable_cookie_domain' => sprintf('<strong>%swp-config.php</strong> could not be written, please edit config and add:<br /><strong style="color:#f00;">define(\'COOKIE_DOMAIN\', \'%s\');</strong> before <strong style="color:#f00;">require_once(ABSPATH . \'wp-settings.php\');</strong>.', ABSPATH, addslashes($cookie_domain)), 'disable_cookie_domain' => sprintf('<strong>%swp-config.php</strong> could not be written, please edit config and add:<br /><strong style="color:#f00;">define(\'COOKIE_DOMAIN\', false);</strong> before <strong style="color:#f00;">require_once(ABSPATH . \'wp-settings.php\');</strong>.', ABSPATH), 'cloudflare_api_request' => 'Unable to make CloudFlare API request.'); $note_messages = array('config_save' => 'Plugin configuration successfully updated.', 'flush_all' => 'All caches successfully emptied.', 'flush_all_except_cf' => 'All caches except CloudFlare successfully emptied.', 'flush_memcached' => 'Memcached cache(s) successfully emptied.', 'flush_opcode' => 'Opcode cache(s) successfully emptied.', 'flush_apc_system' => 'APC system cache successfully emptied', 'flush_file' => 'Disk cache(s) successfully emptied.', 'flush_pgcache' => 'Page cache successfully emptied.', 'flush_dbcache' => 'Database cache successfully emptied.', 'flush_objectcache' => 'Object cache successfully emptied.', 'flush_fragmentcache' => 'Fragment cache successfully emptied.', 'flush_minify' => 'Minify cache successfully emptied.', 'flush_browser_cache' => 'Media Query string has been successfully updated.', 'flush_varnish' => 'Varnish servers successfully purged.', 'flush_cdn' => 'CDN was successfully purged.', 'pgcache_remove_rules_wpsc' => 'WP Super Cache configuration settings have been successfully removed.', 'browsercache_write_rules_no404wp' => 'Browser cache directives have been successfully written.', 'support_request' => 'The support request has been successfully sent.', 'config_import' => 'Settings successfully imported.', 'config_reset' => 'Settings successfully restored.', 'preview_enable' => 'Preview mode was successfully enabled', 'preview_disable' => 'Preview mode was successfully disabled', 'preview_deploy' => 'Preview settings successfully deployed. Preview mode remains enabled until it\'s disabled. Continue testing new settings or disable preview mode if done.', 'cdn_purge_attachment' => 'Attachment successfully purged.', 'pgcache_purge_post' => 'Post successfully purged.', 'pgcache_purge_page' => 'Page successfully purged.', 'new_relic_save' => __('New relic settings have been updated.', 'w3-total-cache')); $errors = array(); $notes = array(); /** * CloudFlare notifications * @var $w3_cloudflare W3_CloudFlare */ $w3_cloudflare = w3_instance('W3_CloudFlare'); if ($error = $w3_cloudflare->check_lasterror()) { $this->_errors[] = $error; } w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); $error = W3_Request::get_string('w3tc_error'); $note = W3_Request::get_string('w3tc_note'); /** * Handle messages from reqeust */ if ($error == 'cloudflare_api_request' && $w3_cloudflare->get_fault_signaled()) { // dont complain twice on cloudflare } elseif (isset($error_messages[$error])) { $errors[] = $error_messages[$error]; } if (isset($note_messages[$note])) { $notes[] = $note_messages[$note]; } $message_id = W3_Request::get_string('w3tc_message'); if ($message_id) { $v = get_transient('w3tc_message.' . $message_id); set_transient('w3tc_message.' . $message_id, null); if (isset($v['errors']) && is_array($v['errors'])) { foreach ($v['errors'] as $error) { if (isset($error_messages[$error])) { $errors[] = $error_messages[$error]; } else { $errors[] = $error; } } } if (isset($v['notes']) && is_array($v['notes'])) { foreach ($v['notes'] as $note) { if (isset($note_messages[$note])) { $notes[] = $note_messages[$note]; } else { $notes[] = $note; } } } } /** * Check config file */ if (w3_get_blog_id() == 0) { global $pagenow; if ($pagenow == 'plugins.php' || strpos(W3_Request::get_string('page'), 'w3tc_') !== false) { $add_in_files = $cache_folders = array(); /** * @var $w3_verify W3_FileVerification * @var $w3_setup W3_Setup */ $w3_verify = w3_instance('W3_FileVerification'); $w3_setup = w3_instance('W3_Setup'); if ($w3_verify->should_create_wp_loader_file()) { try { $result_file = $w3_setup->try_create_wp_loader(); } catch (TryException $ex) { $this->_disable_minify_error_notification = true; $file_data = $w3_setup->w3tc_loader_file_data(); $filename = $file_data['filename']; $data = $file_data['data']; $errors[] = sprintf('<p>Minify and support requests will not function because <strong>%s</strong> is outside the WordPress directory. The plugin needs to add file: <br /><em>%s</em> with the following contents:</p> <pre>%s</pre>', dirname(W3TC_WP_LOADER), $filename, esc_textarea($data)); $this->_ftp_form = $ex->getFtpForm(); } catch (W3TCErrorException $ex) { $this->_disable_minify_error_notification = true; $w3tc_error[] = $ex->getMessage(); } } if (!$w3_verify->verify_filesetup()) { $result_files = $result_folders = false; try { $result_files = $w3_setup->try_create_missing_files(); } catch (TryException $ex) { $add_in_files = $ex->getFiles(); $this->_ftp_form = $ex->getFtpForm(); $this->_disable_add_in_files_notification = true; } catch (W3TCErrorException $ex) { $this->_disable_add_in_files_notification = true; $w3tc_error[] = $ex->getMessage(); } try { $result_folders = $w3_setup->try_create_missing_folders(); } catch (TryException $ex) { $cache_folders = $ex->getFiles(); $this->_ftp_form = $ex->getFtpForm(); $this->_disable_cache_write_notification = true; } catch (W3TCErrorException $ex) { $w3tc_error[] = $ex->getMessage(); $this->_disable_cache_write_notification = true; } catch (TestException $ex) { $results = $ex->getTestResults(); if (isset($results['permissions'])) { $notes = array_merge($notes, $results['permissions']); } else { $errors[] = sprintf('<p>File and directory creation tests failed %s</p> <div class="w3tc-required-changes" style="display:none">%s</div>', $this->button('View required changes', '', 'w3tc-show-required-changes'), $w3_setup->format_test_result($results)); } $this->_disable_cache_write_notification = true; } if ($add_in_files || $cache_folders) { $message = $w3_setup->get_setup_message($cache_folders, $add_in_files, $this->_ftp_form); $errors[] = $message['message']; $this->_ftp_form = $message['ftp_form']; } if ($result_files && $result_folders) { try { if (!$this->_config->own_config_exists()) { $this->update(); if (!$this->_config->own_config_exists()) { $this->_config->save(); $this->_config_admin->save(); } } } catch (FileOperationException $ex) { $cache_folders = array(W3TC_CACHE_DIR, W3TC_CONFIG_DIR, W3TC_CACHE_CONFIG_DIR, W3TC_CACHE_TMP_DIR); $w3tc_error[] = '<strong>W3 Total Cache Error:</strong> Could not save files.<br />Verify that correct (server, S/FTP) <a target="_blank" href="http://codex.wordpress.org/Changing_File_Permissions"> file permissions</a> are set or set FS_CHMOD_* constants in wp-config.php <a href="http://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions"> Learn more</a>. Reload page to restart setup.'; try { if (W3_Request::get_boolean('reset_folders') && check_admin_referer('w3tc')) { w3_require_once(W3TC_INC_DIR . '/functions/activation.php'); w3_wp_delete_folders($cache_folders); } else { $folders = '<ul>'; foreach ($cache_folders as $folder) { $folders .= '<li>' . $folder . '</li>'; } $folders .= '</ul>'; $errors[] = sprintf('<p><form method="POST" action="' . esc_attr($_SERVER['REQUEST_URI']) . '" style="display:inline;"> The plugin cannot create / save the config file to <strong>%s</strong>. Directory may have incorrect permissions.</p><p>Should the plugin remove the plugin directories it has created and restart setup process? ' . wp_nonce_field('w3tc') . '<input name="reset_folders" value="1" type="hidden" /> <input value="Yes, restart setup" type="submit" class="button-secondary"/> </form></p><p>Directories that will be deleted:</p> %s', W3TC_CONFIG_DIR, $folders); } } catch (FilesystemCredentialException $ex) { $form = $ex->ftp_form(); $not_installed = '<ul>'; foreach ($cache_folders as $folder) { $not_installed .= '<li>' . $folder . '</li>'; } $not_installed .= '</ul>'; $headline = $pagenow == 'plugins.php' ? '<h2 id="w3tc">W3 Total Cache Error</h2>' : ''; $errors[] = sprintf('%s<p>Directories could not be removed automatically. Please enter FTP details <a href="#ftp_upload_form">below</a> to complete the reset. %s</p> <div class="w3tc-required-changes" style="display:none">%s</div><p>' . ($cache_folders ? 'The <strong>%s</strong> directory is not write-able.' : '') . '</p>', $headline, $this->button('View required changes', '', 'w3tc-show-required-changes'), $not_installed, WP_CONTENT_DIR); $this->_ftp_form = '<div id="ftp_upload_form" class="updated fade" style="background: none;border: none;">' . str_replace('class="wrap"', '', $form) . '</div>'; $this->_use_ftp_form = true; } catch (FileOperationException $ex) { $not_installed = '<ul>'; foreach ($cache_folders as $folder) { $not_installed .= '<li>' . $folder . '</li>'; } $not_installed .= '</ul>'; $headline = $pagenow == 'plugins.php' ? '<h2 id="w3tc">W3 Total Cache Error</h2>' : ''; $errors[] = sprintf('%s<p>Directories could not be removed automatically. %s</p> <div class="w3tc-required-changes" style="display:none">%s</div>', $headline, $this->button('View required changes', '', 'w3tc-show-required-changes'), $not_installed); } } catch (Exception $e) { } } } elseif ((!defined('W3TC_DISABLE_VERIFY_PERMISSIONS') || defined('W3TC_DISABLE_VERIFY_PERMISSIONS') && !W3TC_DISABLE_VERIFY_PERMISSIONS) && w3_get_blog_id() == 0 && (int) get_transient('test.verify_permissions') <= strtotime('-1 hours')) { w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/activation.php'); try { $results = $w3_setup->test_file_writing(); if ($results) { if (isset($results['permissions'])) { $notes = array_merge($notes, $results['permissions']); } else { $errors[] = sprintf('<p>File and directory creation tests failed %s</p> <div class="w3tc-required-changes" style="display:none">%s</div>', $this->button('View required changes', '', 'w3tc-show-required-changes'), $w3_setup->format_test_result($results)); } } else { set_transient('test.verify_permissions', time()); } } catch (FilesystemCredentialException $ex) { $form = $ex->ftp_form(); $headline = $pagenow == 'plugins.php' ? '<h2 id="w3tc">W3 Total Cache Error</h2>' : ''; $errors[] = sprintf('%s<p>The creation of cache / configuration files failed. <br />The directories with incorrect permissions are: <em>%s</em> and %s. Currently directory permissions are: %s. Please enter FTP details <a href="#ftp_upload_form">below</a> to automatically resolve the issue.</p>', $headline, W3TC_CACHE_DIR, W3TC_CONFIG_DIR, base_convert(w3_get_file_permissions(W3TC_CACHE_DIR), 10, 8)); $this->_ftp_form = '<div id="ftp_upload_form" class="updated fade" style="background:none;border:none;">' . str_replace('class="wrap"', '', $form) . '</div>'; $this->_use_ftp_form = true; } catch (FileOperationException $ex) { $errors[] = sprintf('<p>The creation of cache / configuration files failed. Unfortunately we\'re not able to change permissions from %s:<br /> <em>%s</em> <br /><em>%s</em><br />Directories typically should have at least 755 permissions. If it fails try 775 or 777 until this notification disappears.</p>', base_convert(w3_get_file_permissions(W3TC_CACHE_DIR), 10, 8), W3TC_CACHE_DIR, W3TC_CONFIG_DIR); } } } if (!$this->_disable_cache_write_notification && !$this->_config->own_config_exists() && empty($cache_folders) && strpos(W3_Request::get_string('page'), 'w3tc_') !== false) { $w3tc_error[] = sprintf('<strong>W3 Total Cache Error:</strong> Default settings are in use. The configuration file could not be read or doesn\'t exist. Please %s to create the file.', $this->button_link('save the settings', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_save_config', $this->_page), 'w3tc'))); } } /** * CDN notifications */ if ($this->_config->get_boolean('cdn.enabled') && !w3_is_cdn_mirror($this->_config->get_string('cdn.engine'))) { /** * Show notification after theme change */ if ($this->_config->get_boolean('notes.theme_changed')) { $notes[] = sprintf('The active theme has changed, please %s now to ensure proper operation. %s', $this->button_popup('upload active theme files', 'cdn_export', 'cdn_export_type=theme'), $this->button_hide_note('Hide this message', 'theme_changed')); } /** * Show notification after WP upgrade */ if ($this->_config->get_boolean('notes.wp_upgraded')) { $notes[] = sprintf('Upgraded WordPress? Please %s files now to ensure proper operation. %s', $this->button_popup('upload wp-includes', 'cdn_export', 'cdn_export_type=includes'), $this->button_hide_note('Hide this message', 'wp_upgraded')); } /** * Show notification after CDN enable */ if ($this->_config->get_boolean('notes.cdn_upload') || $this->_config->get_boolean('notes.cdn_reupload')) { $cdn_upload_buttons = array(); if ($this->_config->get_boolean('cdn.includes.enable')) { $cdn_upload_buttons[] = $this->button_popup('wp-includes', 'cdn_export', 'cdn_export_type=includes'); } if ($this->_config->get_boolean('cdn.theme.enable')) { $cdn_upload_buttons[] = $this->button_popup('theme files', 'cdn_export', 'cdn_export_type=theme'); } if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_boolean('cdn.minify.enable') && !$this->_config->get_boolean('minify.auto')) { $cdn_upload_buttons[] = $this->button_popup('minify files', 'cdn_export', 'cdn_export_type=minify'); } if ($this->_config->get_boolean('cdn.custom.enable')) { $cdn_upload_buttons[] = $this->button_popup('custom files', 'cdn_export', 'cdn_export_type=custom'); } if ($this->_config->get_boolean('notes.cdn_upload')) { $notes[] = sprintf('Make sure to %s and upload the %s, files to the <acronym title="Content Delivery Network">CDN</acronym> to ensure proper operation. %s', $this->button_popup('export the media library', 'cdn_export_library'), implode(', ', $cdn_upload_buttons), $this->button_hide_note('Hide this message', 'cdn_upload')); } if ($this->_config->get_boolean('notes.cdn_reupload')) { $notes[] = sprintf('Settings that affect Browser Cache settings for files hosted by the CDN have been changed. To apply the new settings %s and %s. %s', $this->button_popup('export the media library', 'cdn_export_library'), implode(', ', $cdn_upload_buttons), $this->button_hide_note('Hide this message', 'cdn_reupload')); } } /** * Show notification if upload queue is not empty */ if (!$this->is_queue_empty()) { $errors[] = sprintf('The %s has unresolved errors. Empty the queue to restore normal operation.', $this->button_popup('unsuccessful transfer queue', 'cdn_queue')); } } /** * Show notification after plugin activate/deactivate */ if ($this->_config->get_boolean('notes.plugins_updated')) { $texts = array(); if ($this->_config->get_boolean('pgcache.enabled')) { $texts[] = $this->button_link('empty the page cache', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_flush_pgcache', $this->_page), 'w3tc')); } if ($this->_config->get_boolean('minify.enabled')) { $texts[] = sprintf('check the %s to maintain the desired user experience', $this->button_hide_note('minify settings', 'plugins_updated', 'admin.php?page=w3tc_minify')); } if (count($texts)) { $notes[] = sprintf('One or more plugins have been activated or deactivated, please %s. %s', implode(' and ', $texts), $this->button_hide_note('Hide this message', 'plugins_updated')); } } /** * Show notification when page cache needs to be emptied */ if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get('notes.need_empty_pgcache') && !$this->_config->is_preview()) { $notes[] = sprintf('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience.', $this->button_link('Empty the page cache', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_flush_pgcache', $this->_page), 'w3tc'))); } /** * Show notification when object cache needs to be emptied */ if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get('notes.need_empty_objectcache') && !$this->_config->is_preview()) { $notes[] = sprintf('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience.', $this->button_link('Empty the object cache', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_flush_objectcache', $this->_page), 'w3tc'))); } /** * Minify notifications */ if ($this->_config->get_boolean('minify.enabled')) { /** * Minify error occured */ if ($this->_config_admin->get_boolean('notes.minify_error')) { $errors[] = sprintf('Recently an error occurred while creating the CSS / JS minify cache: %s. %s', $this->_config_admin->get_string('minify.error.last'), $this->button_hide_note('Hide this message', 'minify_error', '', true)); } /** * Show notification when minify needs to be emptied */ if ($this->_config->get_boolean('notes.need_empty_minify') && !$this->_config->is_preview()) { $notes[] = sprintf('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience.', $this->button_link('Empty the minify cache', wp_nonce_url(sprintf('admin.php?page=%s&w3tc_flush_minify', $this->_page), 'w3tc'))); } } if ($this->_config->get_boolean('newrelic.enabled')) { /** * @var $nerser W3_NewRelicService */ $nerser = w3_instance('W3_NewRelicService'); $running = $nerser->verify_running(); if (is_array($running)) { $errors[] = __('New Relic is not running correctly. Go to <a href="admin.php?page=w3tc_general#monitoring">New Relic settings</a> to review detected issues.', 'w3-total-cache'); } try { $pl = $nerser->get_frontend_response_time(); if ($pl > 0.3 && $this->_config_admin->get_boolean('notes.new_relic_page_load_notification')) { $nr_recommends = array(); if (!$this->_config->get_boolean('pgcache.enabled')) { $nr_recommends[] = __('Page Cache', 'w3-total-cache'); } if (!$this->_config->get_boolean('minify.enabled')) { $nr_recommends[] = __('Minify', 'w3-total-cache'); } if (!$this->_config->get_boolean('cdn.enabled')) { $nr_recommends[] = __('CDN', 'w3-total-cache'); } if (!$this->_config->get_boolean('browsercache.enabled')) { $nr_recommends[] = __('Browser Cache and use compression', 'w3-total-cache'); } if ($nr_recommends) { $message = sprintf(__('Application monitoring has detected that your page load time is higher than 300ms. It is recommended that you enable the following features: %s %s', 'w3-total-cache'), implode(', ', $nr_recommends), $this->button_hide_note('Hide this message', 'new_relic_page_load_notification', '', true)); $notes[] = $message; } } } catch (Exception $ex) { } } /** * Show notification if user can remove old w3tc folders */ if ($this->_config_admin->get_boolean('notes.remove_w3tc')) { w3_require_once(W3TC_INC_DIR . '/functions/update.php'); $folders = w3_find_old_folders(); $folders = array_map('basename', $folders); $notes[] = sprintf('The directory w3tc can be deleted. %s: %s. However, <em>do not remove the w3tc-config directory</em>. %s', WP_CONTENT_DIR, implode(', ', $folders), $this->button_hide_note('Hide this message', 'remove_w3tc', '', true)); } if (W3_Request::get_string('action') == 'w3tc_deactivate_plugin') { /** * @var $plugins W3_Plugins */ $plugins = w3_instance('W3_Plugins'); $result = $plugins->deactivate(); if ($result['errors']) { $errors = array(); $error_list = '<ul>'; foreach ($result['errors'] as $err) { $error_list .= '<li style="list-style-type: disc;margin-left:20px">' . $err . '</li>'; } $error_list .= '</ul>'; if (isset($result['ftp_form'])) { $this->_ftp_form = '<div id="ftp_upload_form" class="updated fade" style="background: none;border: none;">' . str_replace('class="wrap"', '', $result['ftp_form']) . '</div>'; $this->_use_ftp_form = true; $instruction = '. Please enter FTP details <a href="#ftp_upload_form">below</a> to complete the deactivation.'; } else { $instruction = ' due to the <a target="_blank" href="http://codex.wordpress.org/Changing_File_Permissions">permission settings</a> on your files and directories.'; } $headline = '<h2 id="w3tc">W3 Total Cache Error</h2>'; $errors[] = sprintf('%s<p>Unfortunately directories and files could not be automatically removed to complete the uninstallation%s %s</p> <div class="w3tc-required-changes" style="display:none">%s</div><p>' . 'This error message will automatically disappear once the change is successfully made.</p> ', $headline, $instruction, $this->button('View required changes', '', 'w3tc-show-required-changes'), $error_list, WP_CONTENT_DIR); } else { deactivate_plugins(plugin_basename(W3TC_FILE)); } } foreach ($w3tc_error as $error) { array_unshift($errors, $error); } /** * Show messages */ foreach ($errors as $error) { echo sprintf('<div class="error"><p>%s</p></div>', $error); } foreach ($notes as $note) { echo sprintf('<div class="updated fade"><p>%s</p></div>', $note); } global $pagenow; if (isset($this->_ftp_form) && $pagenow == 'plugins.php') { echo $this->_ftp_form; } }