Esempio n. 1
0
 /**
  * @param W3_Config $config
  * @param W3_ConfigAdmin $config_admin
  * @return string
  */
 function notifications($config)
 {
     /**
      * @var $nerser W3_NewRelicService
      */
     $nerser = w3_instance('W3_NewRelicService');
     try {
         $pl = $nerser->get_frontend_response_time();
         if ($pl > 0.3) {
             $nr_recommends = array();
             if (!$config->get_boolean('pgcache.enabled')) {
                 $nr_recommends[] = __('Page Cache', 'w3-total-cache');
             }
             if (!$config->get_boolean('minify.enabled')) {
                 $nr_recommends[] = __('Minify', 'w3-total-cache');
             }
             if (!$config->get_boolean('cdn.enabled')) {
                 $nr_recommends[] = __('CDN', 'w3-total-cache');
             }
             if (!$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), w3_button_hide_note('Hide this message', 'new_relic_page_load_notification', '', true));
                 return $message;
             }
         }
     } catch (Exception $ex) {
     }
     return '';
 }
Esempio n. 2
0
 /**
  * @param W3_Config $config
  * @param W3_ConfigAdmin|null $config_admin
  * @return array
  */
 function notifications($config, $config_admin)
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     $page = W3_Request::get_string('page');
     $notes = array();
     if (!w3_is_cdn_mirror($config->get_string('cdn.engine'))) {
         /**
          * Show notification after theme change
          */
         if ($config->get_boolean('notes.theme_changed')) {
             $notes[] = sprintf(__('The active theme has changed, please %s now to ensure proper operation. %s', 'w3-total-cache'), w3_button_popup(__('upload active theme files', 'w3-total-cache'), 'cdn_export', 'cdn_export_type=theme'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'theme_changed'));
         }
         /**
          * Show notification after WP upgrade
          */
         if ($config->get_boolean('notes.wp_upgraded')) {
             $notes[] = sprintf(__('Upgraded WordPress? Please %s files now to ensure proper operation. %s', 'w3-total-cache'), w3_button_popup('upload wp-includes', 'cdn_export', 'cdn_export_type=includes'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'wp_upgraded'));
         }
         /**
          * Show notification after CDN enable
          */
         if ($config->get_boolean('notes.cdn_upload') || $config->get_boolean('notes.cdn_reupload')) {
             $cdn_upload_buttons = array();
             if ($config->get_boolean('cdn.includes.enable')) {
                 $cdn_upload_buttons[] = w3_button_popup('wp-includes', 'cdn_export', 'cdn_export_type=includes');
             }
             if ($config->get_boolean('cdn.theme.enable')) {
                 $cdn_upload_buttons[] = w3_button_popup('theme files', 'cdn_export', 'cdn_export_type=theme');
             }
             if ($config->get_boolean('minify.enabled') && $config->get_boolean('cdn.minify.enable') && !$config->get_boolean('minify.auto')) {
                 $cdn_upload_buttons[] = w3_button_popup('minify files', 'cdn_export', 'cdn_export_type=minify');
             }
             if ($config->get_boolean('cdn.custom.enable')) {
                 $cdn_upload_buttons[] = w3_button_popup('custom files', 'cdn_export', 'cdn_export_type=custom');
             }
             if ($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', 'w3-total-cache'), w3_button_popup('export the media library', 'cdn_export_library'), implode(', ', $cdn_upload_buttons), w3_button_hide_note('Hide this message', 'cdn_upload'));
             }
             if ($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', 'w3-total-cache'), w3_button_popup(__('export the media library', 'w3-total-cache'), 'cdn_export_library'), implode(', ', $cdn_upload_buttons), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'cdn_reupload'));
             }
         }
     }
     if (in_array($config->get_string('cdn.engine'), array('netdna', 'maxcdn')) && $config_admin->get_boolean('notes.maxcdn_whitelist_ip') && $config_admin->get_integer('track.maxcdn_authorize') == 0 && $config->get_string('cdn.' . $config->get_string('cdn.engine') . '.authorization_key')) {
         $notes[] = sprintf(__('Make sure to whitelist your servers IPs. Follow the instructions on %s. The IP for this server is %s. %s', 'w3-total-cache'), '<a href="http://support.maxcdn.com/tutorials/how-to-whitelist-your-server-ip-to-use-the-api/">MaxCDN</a>', $_SERVER['SERVER_ADDR'], w3_button_hide_note('Hide this message', 'maxcdn_whitelist_ip', '', true));
     }
     return $notes;
 }
Esempio n. 3
0
 /**
  * @param W3_Config $config
  * @return array
  */
 function notifications($config)
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     $page = W3_Request::get_string('page');
     $notes = array();
     /**
      * Show notification after theme change
      */
     if ($config->get_boolean('notes.theme_changed')) {
         $notes[] = sprintf(__('The active theme has changed, please %s now to ensure proper operation. %s', 'w3-total-cache'), w3_button_popup(__('upload active theme files', 'w3-total-cache'), 'cdn_export', 'cdn_export_type=theme'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'theme_changed'));
     }
     /**
      * Show notification after WP upgrade
      */
     if ($config->get_boolean('notes.wp_upgraded')) {
         $notes[] = sprintf(__('Upgraded WordPress? Please %s files now to ensure proper operation. %s', 'w3-total-cache'), w3_button_popup('upload wp-includes', 'cdn_export', 'cdn_export_type=includes'), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'wp_upgraded'));
     }
     /**
      * Show notification after CDN enable
      */
     if ($config->get_boolean('notes.cdn_upload') || $config->get_boolean('notes.cdn_reupload')) {
         $cdn_upload_buttons = array();
         if ($config->get_boolean('cdn.includes.enable')) {
             $cdn_upload_buttons[] = w3_button_popup('wp-includes', 'cdn_export', 'cdn_export_type=includes');
         }
         if ($config->get_boolean('cdn.theme.enable')) {
             $cdn_upload_buttons[] = w3_button_popup('theme files', 'cdn_export', 'cdn_export_type=theme');
         }
         if ($config->get_boolean('minify.enabled') && $config->get_boolean('cdn.minify.enable') && !$config->get_boolean('minify.auto')) {
             $cdn_upload_buttons[] = w3_button_popup('minify files', 'cdn_export', 'cdn_export_type=minify');
         }
         if ($config->get_boolean('cdn.custom.enable')) {
             $cdn_upload_buttons[] = w3_button_popup('custom files', 'cdn_export', 'cdn_export_type=custom');
         }
         if ($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', 'w3-total-cache'), w3_button_popup('export the media library', 'cdn_export_library'), implode(', ', $cdn_upload_buttons), w3_button_hide_note('Hide this message', 'cdn_upload'));
         }
         if ($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', 'w3-total-cache'), w3_button_popup(__('export the media library', 'w3-total-cache'), 'cdn_export_library'), implode(', ', $cdn_upload_buttons), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'cdn_reupload'));
         }
     }
     return $notes;
 }
 /**
  * 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);
     }
 }
Esempio n. 5
0
    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();
    }
Esempio n. 6
0
 /**
  *  Display edge mode notification
  */
 public function notify_edge_mode()
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin_ui.php');
     $message = sprintf(__('<p>You can now keep W3 Total Cache up-to-date without having to worry about new features breaking your website. There will be more releases with bug fixes, security fixes and settings updates. </p>
     <p>Also, you can now try out our new features as soon as they\'re ready. %s to enable "edge mode" and unlock pre-release features. %s</p>', 'w3-total-cache'), '<a href="' . w3_admin_url(wp_nonce_url('admin.php', 'w3tc') . '&page=' . $this->_page . '&w3tc_edge_mode_enable') . '" class="button">' . __('Click Here', 'w3-total-cache') . '</a>', w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'edge_mode', '', true, '', 'w3tc_default_hide_note_custom'));
     w3_e_notification_box($message, 'edge-mode');
 }
/**
 * @param $extension_name
 * @param $extension_id
 */
function w3_e_extension_activation_notification($extension_name, $extension_id)
{
    w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
    $page = w3tc_get_current_page();
    printf(w3_get_notification_box('<p>' . __('It appears that activating the <a href="%s">%s</a> extension for W3 Total Cache will be helpful for your site. <a class="button" href="%s">Click here</a> to try it. %s', 'w3-total-cache') . '</p>', $extension_id), sprintf(w3_admin_url('admin.php?page=w3tc_extensions#%s'), $extension_id), $extension_name, sprintf(w3_admin_url('admin.php?page=' . $page . '&w3tc_extensions_activate=%s'), $extension_id), w3_button_hide_note(__('Hide this message', 'w3-total-cache'), 'hide-extension-notification', '', true, '', 'w3tc_default_hide_note_custom=' . $extension_id));
}
Esempio n. 8
0
        (<input type="hidden" name="tweeted" value="0" /><label><input type="checkbox" name="tweeted" value="1"<?php 
checked($this->_config->get_boolean('common.tweeted', true));
?>
 /> <?php 
_e('I\'ve tweeted', 'w3-total-cache');
?>
</label>)
        <?php 
echo sprintf(__('and login to wordpress.org to give us a great %srating%s', 'w3-total-cache'), '<input type="button" class="button button-rating" value="', '" />.');
?>
    </p>

    <div style="text-align: center;">
        <h3><?php 
_e('Thanks in advance!', 'w3-total-cache');
?>
</h3>
        <p>
            <?php 
echo $this->nonce_field('w3tc');
?>
        	<input type="submit" class="button-primary" value="<?php 
_e('Save &amp; close', 'w3-total-cache');
?>
"> or
        	<?php 
echo w3_button_hide_note(__('Don\'t show this prompt again', 'w3-total-cache'), 'support_us');
?>
        </p>
    </div>
</form>