Esempio n. 1
0
 /**
  * General tab
  *
  * @return void
  */
 function view()
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
     global $current_user;
     $config_master = $this->_config_master;
     /**
      * @var $modules W3_ModuleStatus
      */
     $modules = w3_instance('W3_ModuleStatus');
     $pgcache_enabled = $modules->is_enabled('pgcache');
     $dbcache_enabled = $modules->is_enabled('dbcache');
     $objectcache_enabled = $modules->is_enabled('objectcache');
     $browsercache_enabled = $modules->is_enabled('browsercache');
     $minify_enabled = $modules->is_enabled('minify');
     $cdn_enabled = $modules->is_enabled('cdn');
     $varnish_enabled = $modules->is_enabled('varnish');
     $fragmentcache_enabled = $modules->is_enabled('fragmentcache');
     $enabled = $modules->plugin_is_enabled();
     $enabled_checkbox = $modules->all_modules_enabled();
     $check_rules = w3_can_check_rules();
     $check_apc = function_exists('apc_store');
     $check_eaccelerator = function_exists('eaccelerator_put');
     $check_xcache = function_exists('xcache_set');
     $check_wincache = function_exists('wincache_ucache_set');
     $check_curl = function_exists('curl_init');
     $check_memcached = class_exists('Memcache');
     $check_ftp = function_exists('ftp_connect');
     $check_tidy = class_exists('tidy');
     $disc_enhanced_enabled = !(!$check_rules || !$this->is_master() && w3_is_network() && $config_master->get_string('pgcache.engine') != 'file_generic');
     $can_empty_file = $modules->can_empty_file();
     $can_empty_varnish = $modules->can_empty_varnish();
     $cdn_mirror_purge = w3_cdn_can_purge_all($modules->get_module_engine('cdn'));
     $file_nfs = $this->_config->get_boolean('pgcache.file.nfs') || $this->_config->get_boolean('minify.file.nfs');
     $file_locking = $this->_config->get_boolean('dbcache.file.locking') || $this->_config->get_boolean('objectcache.file.locking') || $this->_config->get_boolean('pgcache.file.locking') || $this->_config->get_boolean('minify.file.locking');
     w3_require_once(W3TC_LIB_NEWRELIC_DIR . '/NewRelicWrapper.php');
     $newrelic_conf_appname = NewRelicWrapper::get_wordpress_appname($this->_config, $this->_config_master, false);
     $newrelic_applications = array();
     $nerser = w3_instance('W3_NewRelicService');
     $new_relic_installed = $nerser->module_is_enabled();
     $new_relic_running = true;
     if ($this->_config->get_boolean('newrelic.enabled')) {
         $new_relic_configured = $this->_config->get_string('newrelic.api_key') && $this->_config->get_string('newrelic.account_id');
         $newrelic_prefix = '';
         if ($new_relic_configured) {
             if (w3_is_network()) {
                 $newrelic_prefix = $this->_config->get_string('newrelic.appname_prefix');
             }
             try {
                 $newrelic_applications = $nerser->get_applications();
             } catch (Exception $ex) {
             }
             $newrelic_application = $this->_config->get_string('newrelic.application_id');
         }
     }
     $licensing_visible = (!w3_is_multisite() || is_network_admin()) && !ini_get('w3tc.license_key') && get_transient('w3tc_license_status') != 'host_valid';
     $custom_areas = apply_filters("{$this->_page}_anchors", array());
     include W3TC_INC_DIR . '/options/general.php';
 }
 /**
  * Install tab
  *
  * @return void
  */
 function view()
 {
     $rewrite_rules_descriptors = array();
     if (w3_can_check_rules()) {
         /**
          * @var W3_AdminEnvironment $e
          */
         $e = w3_instance('W3_AdminEnvironment');
         $rewrite_rules_descriptors = $e->get_required_rules($this->_config);
         $other_areas = $e->get_other_instructions($this->_config);
     }
     include W3TC_INC_DIR . '/options/install.php';
 }
Esempio n. 3
0
)</code>
            <?php 
} else {
    ?>

            <code>Not defined</code>
            <?php 
}
?>

        </li>

        <li>
            URL rewrite:
            <?php 
if (w3_can_check_rules()) {
    ?>

            <code>Enabled</code>
            <?php 
} else {
    ?>

            <code>Disabled</code>
            <?php 
}
?>

        </li>

        <li>
 /**
  * General tab
  *
  * @return void
  */
 function view()
 {
     global $current_user;
     $config_master = $this->_config_master;
     /**
      * @var $modules W3_ModuleStatus
      */
     $modules = w3_instance('W3_ModuleStatus');
     $pgcache_enabled = $modules->is_enabled('pgcache');
     $dbcache_enabled = $modules->is_enabled('dbcache');
     $objectcache_enabled = $modules->is_enabled('objectcache');
     $browsercache_enabled = $modules->is_enabled('browsercache');
     $minify_enabled = $modules->is_enabled('minify');
     $cdn_enabled = $modules->is_enabled('cdn');
     $cloudflare_enabled = $modules->is_enabled('cloudflare');
     $varnish_enabled = $modules->is_enabled('varnish');
     $fragmentcache_enabled = $modules->is_enabled('fragmentcache');
     $enabled = $modules->plugin_is_enabled();
     $enabled_checkbox = $modules->all_modules_enabled();
     $check_rules = w3_can_check_rules();
     $check_apc = function_exists('apc_store');
     $check_eaccelerator = function_exists('eaccelerator_put');
     $check_xcache = function_exists('xcache_set');
     $check_wincache = function_exists('wincache_ucache_set');
     $check_curl = function_exists('curl_init');
     $check_memcached = class_exists('Memcache');
     $check_ftp = function_exists('ftp_connect');
     $check_tidy = class_exists('tidy');
     $disc_enhanced_enabled = !(!$check_rules || !$this->is_master() && w3_is_network() && $config_master->get_string('pgcache.engine') != 'file_generic');
     $can_empty_file = $modules->can_empty_file();
     $can_empty_varnish = $modules->can_empty_varnish();
     $cdn_mirror_purge = w3_cdn_can_purge_all($modules->get_module_engine('cdn'));
     $cloudflare_signup_email = '';
     $cloudflare_signup_user = '';
     if (is_a($current_user, 'WP_User')) {
         if ($current_user->user_email) {
             $cloudflare_signup_email = $current_user->user_email;
         }
         if ($current_user->user_login && $current_user->user_login != 'admin') {
             $cloudflare_signup_user = $current_user->user_login;
         }
     }
     /**
      * @var $w3_cloudflare W3_CloudFlare
      */
     $w3_cloudflare = w3_instance('W3_CloudFlare');
     $cf_options = $w3_cloudflare->get_options();
     $cloudflare_seclvls = $cf_options['sec_lvl'];
     $cloudflare_devmodes = $cf_options['dev_mode'];
     $cloudflare_rocket_loaders = $cf_options['async'];
     $cloudflare_minifications = $cf_options['minify'];
     $cloudflare_seclvl = 'med';
     $cloudflare_devmode_expire = 0;
     $cloudflare_devmode = 0;
     $cloudflare_rocket_loader = 0;
     $cloudflare_minify = 0;
     if ($cloudflare_enabled && $this->_config->get_string('cloudflare.email') && $this->_config->get_string('cloudflare.key')) {
         $settings = $w3_cloudflare->get_settings();
         $cloudflare_seclvl = $settings['sec_lvl'];
         $cloudflare_devmode_expire = $settings['devmode'];
         $cloudflare_rocket_loader = $settings['async'];
         $cloudflare_devmode = $cloudflare_devmode_expire ? 1 : 0;
         $cloudflare_minify = $settings['minify'];
         $can_empty_cloudflare = true;
     } else {
         $can_empty_cloudflare = false;
     }
     $file_nfs = $this->_config->get_boolean('pgcache.file.nfs') || $this->_config->get_boolean('minify.file.nfs');
     $file_locking = $this->_config->get_boolean('dbcache.file.locking') || $this->_config->get_boolean('objectcache.file.locking') || $this->_config->get_boolean('pgcache.file.locking') || $this->_config->get_boolean('minify.file.locking');
     w3_require_once(W3TC_LIB_NEWRELIC_DIR . '/NewRelicWrapper.php');
     $newrelic_conf_appname = NewRelicWrapper::get_wordpress_appname($this->_config, $this->_config_master, false);
     $newrelic_applications = array();
     $nerser = w3_instance('W3_NewRelicService');
     $new_relic_installed = $nerser->module_is_enabled();
     $new_relic_running = true;
     if ($this->_config->get_boolean('newrelic.enabled')) {
         $new_relic_configured = $this->_config->get_string('newrelic.api_key') && $this->_config->get_string('newrelic.account_id');
         $newrelic_prefix = '';
         if ($new_relic_configured) {
             if (w3_is_network()) {
                 $newrelic_prefix = $this->_config->get_string('newrelic.appname_prefix');
             }
             try {
                 $newrelic_applications = $nerser->get_applications();
             } catch (Exception $ex) {
             }
             $newrelic_application = $this->_config->get_string('newrelic.application_id');
         }
     }
     $licensing_visible = (!w3_is_multisite() || is_network_admin()) && !ini_get('w3tc.license_key') && get_transient('w3tc_license_status') != 'host_valid';
     include W3TC_INC_DIR . '/options/general.php';
 }
Esempio n. 5
0
 /**
  * Install tab
  *
  * @return void
  */
 function options_install()
 {
     $rewrite_rules = array();
     if (w3_can_check_rules()) {
         if ($this->_config->get_boolean('minify.enabled') && $this->_config->get_string('minify.engine') == 'file') {
             require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
             $w3_plugin_minify =& W3_Plugin_Minify::instance();
             $minify_rules_cache_path = w3_get_minify_rules_cache_path();
             if (!isset($rewrite_rules[$minify_rules_cache_path])) {
                 $rewrite_rules[$minify_rules_cache_path] = '';
             }
             $rewrite_rules[$minify_rules_cache_path] .= $w3_plugin_minify->generate_rules_cache();
         }
         if ($this->_config->get_boolean('pgcache.enabled')) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/PgCache.php';
             $w3_plugin_pgcache =& W3_Plugin_PgCache::instance();
             $pgcache_rules_cache_path = w3_get_pgcache_rules_cache_path();
             if (!isset($rewrite_rules[$pgcache_rules_cache_path])) {
                 $rewrite_rules[$pgcache_rules_cache_path] = '';
             }
             $rewrite_rules[$pgcache_rules_cache_path] .= $w3_plugin_pgcache->generate_rules_cache();
         }
         if ($this->_config->get_boolean('browsercache.enabled')) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/BrowserCache.php';
             $w3_plugin_browsercache =& W3_Plugin_BrowserCache::instance();
             $browsercache_rules_cache_path = w3_get_browsercache_rules_cache_path();
             if (!isset($rewrite_rules[$browsercache_rules_cache_path])) {
                 $rewrite_rules[$browsercache_rules_cache_path] = '';
             }
             $rewrite_rules[$browsercache_rules_cache_path] .= $w3_plugin_browsercache->generate_rules_cache();
         }
         if ($this->_config->get_boolean('minify.enabled')) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
             $w3_plugin_minify =& W3_Plugin_Minify::instance();
             $minify_rules_core_path = w3_get_minify_rules_core_path();
             if (!isset($rewrite_rules[$minify_rules_core_path])) {
                 $rewrite_rules[$minify_rules_core_path] = '';
             }
             $rewrite_rules[$minify_rules_core_path] .= $w3_plugin_minify->generate_rules_core();
         }
         if ($this->_config->get_boolean('pgcache.enabled')) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/PgCache.php';
             $w3_plugin_pgcache =& W3_Plugin_PgCache::instance();
             $pgcache_rules_core_path = w3_get_pgcache_rules_core_path();
             if (!isset($rewrite_rules[$pgcache_rules_core_path])) {
                 $rewrite_rules[$pgcache_rules_core_path] = '';
             }
             $rewrite_rules[$pgcache_rules_core_path] .= $w3_plugin_pgcache->generate_rules_core();
         }
         if ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.no404wp')) {
             require_once W3TC_LIB_W3_DIR . '/Plugin/BrowserCache.php';
             $w3_plugin_browsercache =& W3_Plugin_BrowserCache::instance();
             $browsercache_rules_no404wp_path = w3_get_browsercache_rules_no404wp_path();
             if (!isset($rewrite_rules[$browsercache_rules_no404wp_path])) {
                 $rewrite_rules[$browsercache_rules_no404wp_path] = '';
             }
             $rewrite_rules[$browsercache_rules_no404wp_path] .= $w3_plugin_browsercache->generate_rules_no404wp();
         }
         if ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('cdn.enabled') && $this->_config->get_string('cdn.engine') == 'ftp') {
             require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
             $w3_plugin_cdn =& W3_Plugin_Cdn::instance();
             $cdn =& $w3_plugin_cdn->get_cdn();
             $domain = $cdn->get_domain();
             if ($domain) {
                 $cdn_rules_path = sprintf('ftp://%s/%s', $domain, w3_get_cdn_rules_path());
                 if (!isset($rewrite_rules[$cdn_rules_path])) {
                     $rewrite_rules[$cdn_rules_path] = '';
                 }
                 $rewrite_rules[$cdn_rules_path] .= $w3_plugin_browsercache->generate_rules_cache();
             }
         }
         ksort($rewrite_rules);
         reset($rewrite_rules);
     }
     include W3TC_DIR . '/inc/options/install.phtml';
 }
Esempio n. 6
0
checked($browsercache_nocookies, true);
?>
 /> <?php 
_e("Don't set cookies for static files", 'w3-total-cache');
?>
</label>
                    <br /><span class="description"><?php 
_e('Removes Set-Cookie header for responses.');
?>
</span>
                </th>
            </tr>
            <tr>
                <th colspan="2">
                    <?php 
$this->checkbox('browsercache.no404wp', !w3_can_check_rules());
?>
 <?php 
w3_e_config_label('browsercache.no404wp');
?>
</label>
                    <br /><span class="description"><?php 
_e('Reduce server load by allowing the web server to handle 404 (not found) errors for static files (images etc).', 'w3-total-cache');
?>
</span>
                    <br /><span class="description"><?php 
_e('If enabled - tou may get 404 File Not Found response for some files generated on-the-fly by WordPress plugins. You may add those file URIs to 404 error exception list below to avoid that.', 'w3-total-cache');
?>
</span>
                </th>
            </tr>
Esempio n. 7
0
    </p>
</form>

<form id="minify_form" action="admin.php?page=<?php 
echo $this->_page;
?>
" method="post">
    <div class="metabox-holder">
        <?php 
echo $this->postbox_header(__('General', 'w3-total-cache'), '', 'general');
?>
        <table class="form-table">
            <tr>
                <th colspan="2">
                    <?php 
$this->checkbox('minify.rewrite', !w3_can_check_rules() || $minify_rewrite_disabled);
?>
 <?php 
_e('Rewrite <acronym title="Uniform Resource Locator">URL</acronym> structure', 'w3-total-cache');
?>
</label><br />
                    <span class="description"><?php 
_e('If disabled, <acronym title="Cascading Style Sheet">CSS</acronym> and <acronym title="JavaScript">JS</acronym> embeddings will use GET variables instead of "fancy" links.', 'w3-total-cache');
?>
</span>
                </th>
            </tr>
            <tr>
                <th colspan="2">
                    <?php 
$this->checkbox('minify.reject.logged');
Esempio n. 8
0
 /**
  * Returns config value
  *
  * @param string $key
  * @param mixed $default
  * @return mixed
  */
 function get($key, $default = null)
 {
     if (array_key_exists($key, $this->_keys) && array_key_exists($key, $this->_config)) {
         $value = $this->_config[$key];
     } else {
         if ($default === null && array_key_exists($key, $this->_defaults)) {
             $value = $this->_defaults[$key];
         } else {
             $value = $default;
         }
     }
     switch ($key) {
         /**
          * Check cache engines
          */
         case 'pgcache.engine':
         case 'dbcache.engine':
         case 'minify.engine':
         case 'objectcache.engine':
             /**
              * Legacy support
              */
             if ($value == 'file_pgcache') {
                 $value = 'file_generic';
             }
             switch (true) {
                 case $value == 'file_generic' && !w3_can_check_rules():
                 case $value == 'apc' && !function_exists('apc_store'):
                 case $value == 'eaccelerator' && !function_exists('eaccelerator_put'):
                 case $value == 'xcache' && !function_exists('xcache_set'):
                 case $value == 'wincache' && !function_exists('wincache_ucache_set'):
                 case $value == 'memcached' && !class_exists('Memcache'):
                     return 'file';
             }
             break;
             /**
              * Check HTML minifier
              */
         /**
          * Check HTML minifier
          */
         case 'minify.html.engine':
             if ($value == 'htmltidy' && !class_exists('tidy')) {
                 return 'html';
             }
             break;
             /**
              * Disabled some page cache options when enhanced mode enabled
              */
         /**
          * Disabled some page cache options when enhanced mode enabled
          */
         case 'pgcache.cache.query':
             if ($this->get_string('pgcache.engine') == 'file_generic') {
                 return false;
             }
             break;
             /**
              * Set default value to sitemap file
              */
         /**
          * Set default value to sitemap file
          */
         case 'pgcache.prime.sitemap':
             if (!$value) {
                 $value = w3_get_home_url() . '/sitemap.xml';
             }
             break;
             /**
              * Disabled minify when PHP5 is not installed
              */
         /**
          * Disabled minify when PHP5 is not installed
          */
         case 'minify.enabled':
             if (!W3TC_PHP5) {
                 return false;
             }
             break;
             /**
              * Disable minify rewrite when server rules are not supported
              */
         /**
          * Disable minify rewrite when server rules are not supported
          */
         case 'minify.rewrite':
             if (!w3_can_check_rules()) {
                 return false;
             }
             break;
             /**
              * Disable minify options for auto mode
              */
         /**
          * Disable minify options for auto mode
          */
         case 'minify.upload':
             if ($this->get_boolean('minify.auto')) {
                 return false;
             }
             break;
             /**
              * Minify groups legacy support
              */
         /**
          * Minify groups legacy support
          */
         case 'minify.js.groups':
         case 'minify.css.groups':
             /**
              * Support <= 0.8.5.2 versions
              */
             if (is_array($value) && count($value)) {
                 $group = current($value);
                 if (is_array($group) && count($group)) {
                     $location = current($group);
                     if (isset($location['files'])) {
                         if (function_exists('get_theme')) {
                             $theme = get_theme(get_current_theme());
                             $theme_key = w3_get_theme_key($theme['Theme Root'], $theme['Template'], $theme['Stylesheet']);
                             $value = array($theme_key => $value);
                             return $value;
                         }
                     }
                 }
             }
             /**
              * Support <= 0.9.1.3 versions
              */
             $wp_themes = get_themes();
             foreach ($value as $theme_key => $templates) {
                 if (strlen($theme_key) == 5) {
                     break;
                 }
                 foreach ($wp_themes as $wp_theme) {
                     $wp_theme_key = w3_get_theme_key_legacy($wp_theme['Theme Root'], $wp_theme['Template'], $wp_theme['Stylesheet']);
                     if ($theme_key == $wp_theme_key) {
                         $new_theme_key = w3_get_theme_key($wp_theme['Theme Root'], $wp_theme['Template'], $wp_theme['Stylesheet']);
                         $value[$new_theme_key] = $templates;
                         unset($theme_key);
                         break;
                     }
                 }
             }
             break;
             /**
              * Disable CDN minify when PHP5 is not installed or minify is disabled
              */
         /**
          * Disable CDN minify when PHP5 is not installed or minify is disabled
          */
         case 'cdn.minify.enable':
             if (!W3TC_PHP5 || !$this->get_boolean('minify.rewrite') || $this->get_boolean('minify.auto') && !w3_is_cdn_mirror($this->get_string('cdn.engine'))) {
                 return false;
             }
             break;
             /**
              * Check CDN engines
              */
         /**
          * Check CDN engines
          */
         case 'cdn.engine':
             /**
              * Check for PHP5
              */
             if (in_array($value, array('rscf', 'azure')) && !W3TC_PHP5) {
                 return 'mirror';
             }
             /**
              * Check for CURL
              */
             if (in_array($value, array('s3', 'cf', 'cf2', 'rscf')) && !function_exists('curl_init')) {
                 return 'mirror';
             }
             /**
              * Check for FTP
              */
             if ($value == 'ftp' && !function_exists('ftp_connect')) {
                 return 'mirror';
             }
             /**
              * Check for SHA 256 functions
              */
             if ($value == 'netdna' && !function_exists('hash') && !function_exists('mhash')) {
                 return 'mirror';
             }
             break;
             /**
              * Disable no 404 wp feature when server rules are not supported
              */
         /**
          * Disable no 404 wp feature when server rules are not supported
          */
         case 'browsercache.no404wp':
             if (!w3_can_check_rules()) {
                 return false;
             }
             break;
     }
     return $value;
 }
 /**
  * Install tab
  *
  * @return void
  */
 function options_install()
 {
     $rewrite_rules_descriptors = array();
     if (w3_can_check_rules()) {
         $e = w3_instance('W3_AdminEnvironment');
         $rewrite_rules_descriptors = $e->get_required_rules($this->_config);
     }
     include W3TC_INC_DIR . '/options/install.php';
 }
 /**
  * Install tab
  *
  * @return void
  */
 function options_install()
 {
     $rewrite_rules_descriptors = array();
     if (w3_can_check_rules()) {
         $plugins = w3_instance('W3_Plugins');
         $rewrite_rules_descriptors = $plugins->get_required_rules();
     }
     include W3TC_INC_DIR . '/options/install.php';
 }