/** * Returns hide note button html * * @param string $text * @param string $note * @param string $redirect * @param boolean $admin if to use config admin * @param string $page * @return string */ function w3_button_hide_note($text, $note, $redirect = '', $admin = false, $page = '') { if ($page == '') { w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); $page = W3_Request::get_string('page', 'w3tc_dashboard'); } $url = sprintf('admin.php?page=%s&w3tc_default_hide_note¬e=%s', $page, $note); if ($admin) { $url .= '&admin=1'; } if ($redirect != '') { $url .= '&redirect=' . urlencode($redirect); } $url = wp_nonce_url($url, 'w3tc'); return w3_button_link($text, $url); }
/** * Admin notices action * * @return void */ function admin_notices() { w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin_ui.php'); w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin.php'); $cookie_domain = w3_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.', 'w3-total-cache'), w3_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\'.', 'w3-total-cache'), w3_button_link('enable', 'options-permalink.php')), 'support_request_type' => __('Please select request type.', 'w3-total-cache'), 'support_request_url' => __('Please enter the address of the site in the site <acronym title="Uniform Resource Locator">URL</acronym> field.', 'w3-total-cache'), 'support_request_name' => __('Please enter your name in the Name field', 'w3-total-cache'), 'support_request_email' => __('Please enter valid email address in the E-Mail field.', 'w3-total-cache'), 'support_request_phone' => __('Please enter your phone in the phone field.', 'w3-total-cache'), 'support_request_subject' => __('Please enter subject in the subject field.', 'w3-total-cache'), 'support_request_description' => __('Please describe the issue in the issue description field.', 'w3-total-cache'), 'support_request_wp_login' => __('Please enter an administrator login. Create a temporary one just for this support case if needed.', 'w3-total-cache'), 'support_request_wp_password' => __('Please enter WP Admin password, be sure it\'s spelled correctly.', 'w3-total-cache'), 'support_request_ftp_host' => __('Please enter <acronym title="Secure Shell">SSH</acronym> or <acronym title="File Transfer Protocol">FTP</acronym> host for the site.', 'w3-total-cache'), '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.', 'w3-total-cache'), '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.', 'w3-total-cache'), 'support_request' => __('Unable to send the support request.', 'w3-total-cache'), 'config_import_no_file' => __('Please select config file.', 'w3-total-cache'), 'config_import_upload' => __('Unable to upload config file.', 'w3-total-cache'), 'config_import_import' => __('Configuration file could not be imported.', 'w3-total-cache'), '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.', 'w3-total-cache'), W3TC_CONFIG_DIR), 'cdn_purge_attachment' => __('Unable to purge attachment.', 'w3-total-cache'), 'pgcache_purge_post' => __('Unable to purge post.', 'w3-total-cache'), 'pgcache_purge_page' => __('Unable to purge page.', 'w3-total-cache'), '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>.', 'w3-total-cache'), 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>.', 'w3-total-cache'), ABSPATH), 'cloudflare_api_request' => __('Unable to make CloudFlare API request.', 'w3-total-cache')); $note_messages = array('config_save' => __('Plugin configuration successfully updated.', 'w3-total-cache'), 'flush_all' => __('All caches successfully emptied.', 'w3-total-cache'), 'flush_all_except_cf' => __('All caches except CloudFlare successfully emptied.', 'w3-total-cache'), 'flush_memcached' => __('Memcached cache(s) successfully emptied.', 'w3-total-cache'), 'flush_opcode' => __('Opcode cache(s) successfully emptied.', 'w3-total-cache'), 'flush_apc_system' => __('APC system cache successfully emptied', 'w3-total-cache'), 'flush_file' => __('Disk cache(s) successfully emptied.', 'w3-total-cache'), 'flush_pgcache' => __('Page cache successfully emptied.', 'w3-total-cache'), 'flush_dbcache' => __('Database cache successfully emptied.', 'w3-total-cache'), 'flush_objectcache' => __('Object cache successfully emptied.', 'w3-total-cache'), 'flush_fragmentcache' => __('Fragment cache successfully emptied.', 'w3-total-cache'), 'flush_minify' => __('Minify cache successfully emptied.', 'w3-total-cache'), 'flush_browser_cache' => __('Media Query string has been successfully updated.', 'w3-total-cache'), 'flush_varnish' => __('Varnish servers successfully purged.', 'w3-total-cache'), 'flush_cdn' => __('CDN was successfully purged.', 'w3-total-cache'), 'support_request' => __('The support request has been successfully sent.', 'w3-total-cache'), 'config_import' => __('Settings successfully imported.', 'w3-total-cache'), 'config_reset' => __('Settings successfully restored.', 'w3-total-cache'), 'preview_enable' => __('Preview mode was successfully enabled', 'w3-total-cache'), 'preview_disable' => __('Preview mode was successfully disabled', 'w3-total-cache'), 'preview_deploy' => __('Preview settings successfully deployed. Preview mode remains enabled until it\'s disabled. Continue testing new settings or disable preview mode if done.', 'w3-total-cache'), 'cdn_purge_attachment' => __('Attachment successfully purged.', 'w3-total-cache'), 'pgcache_purge_post' => __('Post successfully purged.', 'w3-total-cache'), 'pgcache_purge_page' => __('Page successfully purged.', 'w3-total-cache'), 'new_relic_save' => __('New relic settings have been updated.', 'w3-total-cache'), 'add_in_removed' => __('The add-in has been removed.', 'w3-total-cache')); $errors = array(); $notes = array(); $environment_error_present = false; // print errors happened during last request execution, // when we decided to redirect with error message instead of // printing it directly (to avoid reexecution on refresh) $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; } } } } /* * Filesystem environment fix, if needed */ try { global $pagenow; if ($pagenow == 'plugins.php' || substr(W3_Request::get_string('page'), 0, 5) == 'w3tc_') { $environment = w3_instance('W3_AdminEnvironment'); $environment->fix_in_wpadmin($this->_config); if (isset($_REQUEST['upgrade'])) { $notes[] = __('Required files and directories have been automatically created', 'w3-total-cache'); } } } catch (SelfTestExceptions $exs) { $r = w3_parse_selftest_exceptions($exs); foreach ($r['before_errors'] as $e) { $errors[] = $e; } if (strlen($r['required_changes']) > 0) { $changes_style = 'border: 1px solid black; ' . 'background: white; ' . 'margin: 10px 30px 10px 30px; ' . 'padding: 10px; display: none'; $ftp_style = 'border: 1px solid black; background: white; ' . 'margin: 10px 30px 10px 30px; ' . 'padding: 10px; display: none'; $ftp_form = str_replace('class="wrap"', '', $exs->credentials_form()); $ftp_form = str_replace('<form ', '<form name="w3tc_ftp_form" ', $ftp_form); $ftp_form = str_replace('<fieldset>', '', $ftp_form); $ftp_form = str_replace('</fieldset>', '', $ftp_form); $ftp_form = str_replace('id="upgrade" class="button"', 'id="upgrade" class="button w3tc-button-save"', $ftp_form); $error = '<strong>W3 Total Cache Error:</strong> ' . 'Files and directories could not be automatically ' . 'created to complete the installation. ' . '<table>' . '<tr>' . '<td>Please execute commands manually</td>' . '<td>' . w3_button('View required changes', '', 'w3tc-show-required-changes') . '</td>' . '</tr>' . '<tr>' . '<td>or use FTP form to allow ' . '<strong>W3 Total Cache</strong> make it automatically.' . '</td>' . '<td>' . w3_button('Update via FTP', '', 'w3tc-show-ftp-form') . '</td>' . '</tr></table>' . '<div class="w3tc-required-changes" style="' . $changes_style . '">' . $r['required_changes'] . '</div>' . '<div class="w3tc-ftp-form" style="' . $ftp_style . '">' . $ftp_form . '</div>'; $environment_error_present = true; $errors[] = $error; } foreach ($r['later_errors'] as $e) { $errors[] = $e; } } /** * 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]; } /** * CDN notifications */ if ($this->_config->get_boolean('cdn.enabled') && !w3_is_cdn_mirror($this->_config->get_string('cdn.engine'))) { /** * @var $ui_cdn_notes W3_UI_CdnNotes */ $cdn_notes = w3_instance('W3_UI_CdnNotes'); $this->_notes = array_merge($this->_notes, $cdn_notes->notifications($this->_config)); $this->_errors = array_merge($this->_errors, $cdn_notes->errors()); } /** * Show notification after plugin activate/deactivate */ if ($this->_config->get_boolean('notes.plugins_updated')) { $texts = array(); if ($this->_config->get_boolean('pgcache.enabled')) { $texts[] = w3_button_link(__('empty the page cache', 'w3-total-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', 'w3-total-cache'), w3_button_hide_note(__('minify settings', 'w3-total-cache'), 'plugins_updated', 'admin.php?page=w3tc_minify')); } if (count($texts)) { $notes[] = sprintf(__('One or more plugins have been activated or deactivated, please %s. %s', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $texts), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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.', w3_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.', 'w3-total-cache'), w3_button_link(__('Empty the object cache', 'w3-total-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', 'w3-total-cache'), $this->_config_admin->get_string('minify.error.last'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), '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.', 'w3-total-cache'), w3_button_link(__('Empty the minify cache', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_flush_minify', $this->_page), 'w3tc'))); } } if ($this->_config->get_boolean('newrelic.enabled') && $this->_config_admin->get_boolean('notes.new_relic_page_load_notification')) { /** * @var W3_UI_NewRelicNotes $newrelic_notes */ $newrelic_notes = w3_instance('W3_UI_NewRelicNotes'); $this->_notes = array_merge($this->_notes, $newrelic_notes->notifications($this->_config)); } /** * 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', 'w3-total-cache'), WP_CONTENT_DIR, implode(', ', $folders), w3_button_hide_note('Hide this message', 'remove_w3tc', '', true)); } // print errors which happened during current request execution foreach ($this->_errors as $error) { $errors[] = $error; } // print notes which happened during current request execution foreach ($this->_notes as $note) { $notes[] = $note; } /** * Show messages */ foreach ($notes as $note) { echo sprintf('<div class="updated fade"><p>%s</p></div>', $note); } foreach ($errors as $error) { echo sprintf('<div class="error"><p>%s</p></div>', $error); } }
function options() { $remove_results = array(); $w3tc_error = array(); w3_require_once(W3TC_INC_DIR . '/functions/activation.php'); $preview = $this->_config->is_preview(); if (w3_is_network() && !$this->is_master()) { $this->_config_master = new W3_Config(true); } else { $this->_config_master = $this->_config; } /** * Check for page cache availability */ $wp_config_edit = false; /** * Check memcached */ $memcaches_errors = array(); if ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'memcached') { $pgcache_memcached_servers = $this->_config->get_array('pgcache.memcached.servers'); if (!$this->is_memcache_available($pgcache_memcached_servers)) { $memcaches_errors[] = sprintf(__('Page Cache: %s.', 'w3-total-cache'), implode(', ', $pgcache_memcached_servers)); } } if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_string('minify.engine') == 'memcached') { $minify_memcached_servers = $this->_config->get_array('minify.memcached.servers'); if (!$this->is_memcache_available($minify_memcached_servers)) { $memcaches_errors[] = sprintf(__('Minify: %s.', 'w3-total-cache'), implode(', ', $minify_memcached_servers)); } } if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_string('dbcache.engine') == 'memcached') { $dbcache_memcached_servers = $this->_config->get_array('dbcache.memcached.servers'); if (!$this->is_memcache_available($dbcache_memcached_servers)) { $memcaches_errors[] = sprintf(__('Database Cache: %s.', 'w3-total-cache'), implode(', ', $dbcache_memcached_servers)); } } if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get_string('objectcache.engine') == 'memcached') { $objectcache_memcached_servers = $this->_config->get_array('objectcache.memcached.servers'); if (!$this->is_memcache_available($objectcache_memcached_servers)) { $memcaches_errors[] = sprintf(__('Object Cache: %s.', 'w3-total-cache'), implode(', ', $objectcache_memcached_servers)); } } if (count($memcaches_errors)) { $memcache_error = __('The following memcached servers are not responding or not running:</p><ul>', 'w3-total-cache'); foreach ($memcaches_errors as $memcaches_error) { $memcache_error .= '<li>' . $memcaches_error . '</li>'; } $memcache_error .= __('</ul><p>This message will automatically disappear once the issue is resolved.', 'w3-total-cache'); $this->_errors[] = $memcache_error; } /** * Check CURL extension */ if ($this->_config->get_boolean('notes.no_curl') && $this->_config->get_boolean('cdn.enabled') && !function_exists('curl_init')) { $this->_notes[] = sprintf(__('The <strong>CURL PHP</strong> extension is not available. Please install it to enable S3 or CloudFront functionality. %s', 'w3-total-cache'), w3_button_hide_note('Hide this message', 'no_curl')); } /** * Check Zlib extension */ if ($this->_config->get_boolean('notes.no_zlib') && !function_exists('gzencode')) { $this->_notes[] = sprintf(__('Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Notify the server administrator. %s', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'no_zlib')); } /** * Check if Zlib output compression is enabled */ if ($this->_config->get_boolean('notes.zlib_output_compression') && w3_zlib_output_compression()) { $this->_notes[] = sprintf(__('Either the PHP configuration, web server configuration or a script in the WordPress installation has <strong>zlib.output_compression</strong> enabled.<br />Please locate and disable this setting to ensure proper HTTP compression behavior. %s', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'zlib_output_compression')); } /** * Check wp-content permissions */ if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_perms')) { w3_require_once(W3TC_INC_DIR . '/functions/file.php'); $wp_content_mode = w3_get_file_permissions(WP_CONTENT_DIR); if ($wp_content_mode > 0755) { $this->_notes[] = sprintf(__('<strong>%s</strong> is write-able. When finished installing the plugin, change the permissions back to the default: <strong>chmod 755 %s</strong>. Permissions are currently %s. %s', 'w3-total-cache'), WP_CONTENT_DIR, WP_CONTENT_DIR, base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'wp_content_perms')); } } /** * Check wp-content permissions */ if (!W3TC_WIN && $this->_config->get_boolean('notes.wp_content_changed_perms')) { $perm = get_transient('w3tc_prev_permission'); $current_perm = w3_get_file_permissions(WP_CONTENT_DIR); if ($perm && $perm != base_convert($current_perm, 10, 8) && ($current_perm > 0755 || $perm < base_convert($current_perm, 10, 8))) { $this->_notes[] = sprintf(__('<strong>%s</strong> permissions were changed during the setup process. Permissions are currently %s.<br />To restore permissions run <strong>chmod %s %s</strong>. %s', 'w3-total-cache'), WP_CONTENT_DIR, base_convert($current_perm, 10, 8), $perm, WP_CONTENT_DIR, w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'wp_content_changed_perms')); } } /** * Check permalinks */ if ($this->_config->get_boolean('notes.no_permalink_rules') && ($this->_config->get_boolean('pgcache.enabled') && $this->_config->get_string('pgcache.engine') == 'file_generic' || $this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.no404wp')) && !w3_is_permalink_rules()) { $this->_errors[] = sprintf(__('The required directives for fancy permalinks could not be detected, please confirm they are available: <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">Creating and editing</a> %s', 'w3-total-cache'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'no_permalink_rules')); } /** * CDN */ if ($this->_config->get_boolean('cdn.enabled')) { /** * Check upload settings */ $upload_info = w3_upload_info(); if (!$upload_info) { $upload_path = get_option('upload_path'); $upload_path = trim($upload_path); if (empty($upload_path)) { $upload_path = WP_CONTENT_DIR . '/uploads'; $this->_errors[] = sprintf(__('The uploads directory is not available. Default WordPress directories will be created: <strong>%s</strong>.', 'w3-total-cache'), $upload_path); } if (!w3_is_multisite()) { $this->_errors[] = sprintf(__('The uploads path found in the database (%s) is inconsistent with the actual path. Please manually adjust the upload path either in miscellaneous settings or if not using a custom path %s automatically to resolve the issue.', 'w3-total-cache'), $upload_path, w3_button_link(__('update the path', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_update_upload_path', $this->_page), 'w3tc'))); } } /** * Check CDN settings */ $cdn_engine = $this->_config->get_string('cdn.engine'); $error = ''; switch (true) { case $cdn_engine == 'ftp' && !count($this->_config->get_array('cdn.ftp.domain')): $this->_errors[] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: The <strong>"Replace default hostname with"</strong> field cannot be empty. Enter <acronym title="Content Delivery Network">CDN</acronym> provider hostname <a href="?page=w3tc_cdn#configuration">here</a>. <em>(This is the hostname used in order to view objects in a browser.)</em>', 'w3-total-cache'); break; case $cdn_engine == 's3' && ($this->_config->get_string('cdn.s3.key') == '' || $this->_config->get_string('cdn.s3.secret') == '' || $this->_config->get_string('cdn.s3.bucket') == ''): $error = __('The <strong>"Access key", "Secret key" and "Bucket"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'cf' && ($this->_config->get_string('cdn.cf.key') == '' || $this->_config->get_string('cdn.cf.secret') == '' || $this->_config->get_string('cdn.cf.bucket') == '' || $this->_config->get_string('cdn.cf.id') == '' && !count($this->_config->get_array('cdn.cf.cname'))): $error = __('The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'cf2' && ($this->_config->get_string('cdn.cf2.key') == '' || $this->_config->get_string('cdn.cf2.secret') == '' || $this->_config->get_string('cdn.cf2.id') == '' && !count($this->_config->get_array('cdn.cf2.cname'))): $error = __('The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'rscf' && ($this->_config->get_string('cdn.rscf.user') == '' || $this->_config->get_string('cdn.rscf.key') == '' || $this->_config->get_string('cdn.rscf.container') == '' || !count($this->_config->get_array('cdn.rscf.cname'))): $error = __('The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'azure' && ($this->_config->get_string('cdn.azure.user') == '' || $this->_config->get_string('cdn.azure.key') == '' || $this->_config->get_string('cdn.azure.container') == ''): $error = __('The <strong>"Account name", "Account key" and "Container"</strong> fields cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'mirror' && !count($this->_config->get_array('cdn.mirror.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'netdna': $fields = array(); if ($this->_config->get_string('cdn.netdna.authorization_key') == '') { $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"'; } if (!count($this->_config->get_array('cdn.netdna.domain'))) { $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"'; } if ($fields) { $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields)); } if ($this->_config->get_string('cdn.netdna.authorization_key') != '' && sizeof(explode('+', $this->_config->get_string('cdn.netdna.authorization_key'))) != 3) { $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache'); } elseif ($this->_config->get_integer('cdn.netdna.zone_id', 0) <= 0) { $error .= __('You need to select / create a pull zone.', 'w3-total-cache'); } break; case $cdn_engine == 'maxcdn': $fields = array(); if ($this->_config->get_string('cdn.maxcdn.authorization_key') == '') { $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"'; } if (!count($this->_config->get_array('cdn.maxcdn.domain'))) { $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"'; } if ($fields) { $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields)); } if ($this->_config->get_string('cdn.maxcdn.authorization_key') != '' && sizeof(explode('+', $this->_config->get_string('cdn.maxcdn.authorization_key'))) != 3) { $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache'); } elseif ($this->_config->get_integer('cdn.maxcdn.zone_id', 0) <= 0) { $error .= __('You need to select / create a pull zone.', 'w3-total-cache'); } break; case $cdn_engine == 'cotendo' && !count($this->_config->get_array('cdn.cotendo.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'edgecast' && !count($this->_config->get_array('cdn.edgecast.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'att' && !count($this->_config->get_array('cdn.att.domain')): $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache'); break; case $cdn_engine == 'akamai' && !count($this->_config->get_array('cdn.akamai.domain')): $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.'; break; } if ($error) { $this->_errors[] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: ', 'w3-total-cache') . $error . __(' <a href="?page=w3tc_cdn#configuration">Specify it here</a>.', 'w3-total-cache'); } } /** * Preview mode */ if ($this->_config->is_preview()) { $this->_notes[] = sprintf(__('Preview mode is active: Changed settings will not take effect until preview mode is %s or %s.', 'w3-total-cache'), w3_button_link(__('deploy', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_preview_deploy', $this->_page), 'w3tc')), w3_button_link(__('disable', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_preview_disable', $this->_page), 'w3tc'))) . '<br /><span class="description">' . sprintf(__('To preview any changed settings (without deploying): %s', 'w3-total-cache'), w3tc_get_preview_link()) . '</span>'; } /** * */ if ($this->_config->get_boolean('notes.root_rules') && count($this->_rule_errors_root) > 0) { $this->_rule_errors_root_hide = w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'root_rules'); } else { $this->_rule_errors_root = array(); } $this->_disable_file_operation_notification = $this->_disable_add_in_files_notification || $this->_disable_cache_write_notification; if (!$this->_disable_file_operation_notification && isset($file_operation_exception) && $file_operation_exception) { $tech_message = '<ul>'; $core_rules_perms = ''; if (w3_get_file_permissions(w3_get_wp_config_path()) != 0644) { $core_config_perms = sprintf(__('File permissions are <strong>%s</strong>, however they should be <strong>644</strong>.', 'w3-total-cache'), base_convert(w3_get_file_permissions(w3_get_wp_config_path()), 10, 8)); } else { $core_config_perms = sprintf(__('File permissions are <strong>%s</strong>', 'w3-total-cache'), base_convert(w3_get_file_permissions(w3_get_wp_config_path()), 10, 8)); } if (w3_get_file_permissions(w3_get_pgcache_rules_core_path()) != 0644) { $core_rules_perms = sprintf(__('File permissions are <strong>%s</strong>, however they should be <strong>644</strong>.', 'w3-total-cache'), base_convert(w3_get_file_permissions(w3_get_pgcache_rules_core_path()), 10, 8)); } else { $core_rules_perms = sprintf(__('File permissions are <strong>%s</strong>', 'w3-total-cache'), base_convert(w3_get_file_permissions(w3_get_pgcache_rules_core_path()), 10, 8)); } $wp_content_perms = ''; if (w3_get_file_permissions(WP_CONTENT_DIR) != 0755) { $wp_content_perms = sprintf(__('Directory permissions are <strong>%s</strong>, however they should be <strong>755</strong>.', 'w3-total-cache'), base_convert(w3_get_file_permissions(WP_CONTENT_DIR), 10, 8)); } $tech_message .= '<li>' . sprintf(__('File: <strong>%s</strong> %s File owner: %s', 'w3-total-cache'), w3_get_wp_config_path(), $core_config_perms, w3_get_file_owner(w3_get_wp_config_path())) . '</li>'; $tech_message .= '<li>' . sprintf(__('File: <strong>%s</strong> %s File owner: %s', 'w3-total-cache'), w3_get_pgcache_rules_core_path(), $core_rules_perms, w3_get_file_owner(w3_get_pgcache_rules_core_path())) . '</li>'; $tech_message .= '<li>' . sprintf(__('Directory: <strong>%s</strong> %s File owner: %s', 'w3-total-cache'), WP_CONTENT_DIR, $wp_content_perms, w3_get_file_owner(WP_CONTENT_DIR)) . '</li>'; $tech_message .= '<li>' . sprintf(__('Owner of current file: %s', 'w3-total-cache'), w3_get_file_owner()) . '</li>'; if (!(w3_get_file_owner() == w3_get_file_owner(w3_get_pgcache_rules_core_path()) && w3_get_file_owner() == w3_get_file_owner(WP_CONTENT_DIR))) { $tech_message .= __('<li>The files and directories have different ownership, they should have the same ownership. </li>', 'w3-total-cache'); } $tech_message .= '</ul>'; $tech_message = '<div class="w3tc-technical-info" style="display:none">' . $tech_message . '</div>'; $w3tc_error[] = sprintf(__('<strong>W3 Total Cache Error:</strong> The plugin tried to edit, %s, but failed. Files and directories cannot be modified. Please review your <a target="_blank" href="http://codex.wordpress.org/Changing_File_Permissions"> file permissions</a>. A common cause is %s and %s having different ownership or permissions. %s %s', 'w3-total-cache'), $wp_config_edit ? w3_get_wp_config_path() : w3_get_pgcache_rules_core_path(), $wp_config_edit ? basename(w3_get_wp_config_path()) : basename(w3_get_pgcache_rules_core_path()), WP_CONTENT_DIR, w3_button(__('View technical information', 'w3-total-cache'), '', 'w3tc-show-technical-info'), $tech_message); } /** * Remove functions results */ if ($remove_results) { foreach ($remove_results as $result) { $this->_errors = array_merge($this->_errors, $result['errors']); if (!isset($this->_ftp_form) && isset($result['ftp_form'])) { $extra_ftp_message = __('Please enter FTP details <a href="#ftp_upload_form">below</a> to remove the disabled modules. ', 'w3-total-cache'); $this->_ftp_form = $result['ftp_form']; $this->_use_ftp_form = true; } } if (isset($extra_ftp_message)) { $this->_errors[] = $extra_ftp_message; } } foreach ($w3tc_error as $error) { array_unshift($this->_errors, $error); } if (isset($this->_ftp_form)) { $this->_use_ftp_form = true; } $this->view(); }
function w3tc_action_button($action, $url, $class = '') { return w3_button_link($action, $url, false, $class); }
/** * Returns a preview link with current state * @return string */ function w3tc_get_preview_link() { w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php'); return w3_is_preview_mode() ? w3_button_link(__('Stop Previewing', 'w3-total-cache'), wp_nonce_url(w3_admin_url('admin.php?page=w3tc_dashboard&w3tc_default_stop_previewing'), 'w3tc'), false) : w3_button_link(__('Preview', 'w3-total-cache'), wp_nonce_url(w3_admin_url('admin.php?page=w3tc_dashboard&w3tc_default_previewing'), 'w3tc'), true); }
<td> <?php echo $this->nonce_field('w3tc'); ?> <?php if ($this->_config->is_preview()) { ?> <input type="submit" name="w3tc_config_preview_disable" class="button-primary" value="<?php _e('Disable', 'w3-total-cache'); ?> " /> <?php echo w3_button_link(__('Preview', 'w3-total-cache'), w3_get_home_url() . '/?w3tc_preview=1', true); ?> <?php echo w3_button_link(__('Deploy', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_config_preview_deploy', $this->_page), 'w3tc')); ?> <?php } else { ?> <input type="submit" name="w3tc_config_preview_enable" class="button-primary" value="<?php _e('Enable', 'w3-total-cache'); ?> " /> <?php } ?> <br /><span class="description"><?php _e('Use preview mode to test configuration scenarios prior to releasing them (deploy) on the actual site. Preview mode remains active even after deploying settings until the feature is disabled.', 'w3-total-cache'); ?> </span>
switch ($_GET['caching']) { case "cloudflare": ?> It looks like you have CloudFlare running on your site, don't forget to <a href="https://www.cloudflare.com/cloudflare-settings?z=<?php echo parse_url(get_bloginfo('url'), PHP_URL_HOST); ?> #page=overview" target="_blank">Purge cache</a>. <?php break; ?> <?php case "w3-total-cache": ?> It looks like you are running W3 Total Cache on your site, <?php echo w3_button_link(__('empty the page cache', 'w3-total-cache'), wp_nonce_url('admin.php?page=w3tc_dashboard&w3tc_flush_pgcache', 'w3tc')); ?> for Filament to work properly. <?php break; ?> <?php case "wp-super-cache": ?> It looks like you are running WP Super Cache on your site, don't forget to <a href="<?php echo admin_url('options-general.php?page=wpsupercache'); ?> ">Delete cache</a>. <?php break;