function generate() { $pages = $this->generate_menu_array(); add_menu_page(__('Performance', 'w3-total-cache'), __('Performance', 'w3-total-cache'), 'manage_options', 'w3tc_dashboard', '', 'div'); $submenu_pages = array(); foreach ($pages as $slug => $titles) { if ($this->_config_admin->get_boolean('common.visible_by_master_only') && $titles['network_show'] || (!$this->_config_admin->get_boolean('common.visible_by_master_only') || is_super_admin() && (!w3_force_master() || is_network_admin()))) { $submenu_pages[] = add_submenu_page('w3tc_dashboard', $titles[0] . ' | W3 Total Cache', $titles[1], 'manage_options', $slug, array(&$this, 'options')); } } return $submenu_pages; }
/** * Page cache tab * * @return void */ function view() { global $wp_rewrite; $feeds = $wp_rewrite->feeds; $feed_key = array_search('feed', $feeds); if ($feed_key !== false) { unset($feeds[$feed_key]); } $default_feed = get_default_feed(); $pgcache_enabled = $this->_config->get_boolean('pgcache.enabled'); $permalink_structure = get_option('permalink_structure'); $varnish_enabled = $this->_config->get_boolean('varnish.enabled'); $cdn_mirror_purge_enabled = w3_is_cdn_mirror($this->_config->get_string('cdn.engine')) && $this->_config->get_string('cdn.engine') != 'mirror' && $this->_config->get_boolean('cdncache.enabled') && w3tc_edge_mode() && w3_is_pro($this->_config) || w3_is_enterprise(); $disable_check_domain = w3_is_multisite() && w3_force_master(); include W3TC_INC_DIR . '/options/pgcache.php'; }
function print_script() { ?> <script type="text/javascript"> var w3_use_network_link = <?php echo is_network_admin() || w3_is_multisite() && w3_force_master() ? 'true' : 'false'; ?> ; function w3tc_start_minify_try_solve() { var testUrl = '<?php echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/', w3_get_domain(w3_get_home_url()) != w3_get_domain(w3_get_site_url())); ?> '; w3tc_filename_auto_solve(testUrl); } </script> <?php }
function print_script() { ?> <script type="text/javascript"> var w3_use_network_link = <?php echo w3_force_master() ? 'true' : 'false'; ?> ; function w3tc_start_minify_try_solve() { var testUrl = '<?php echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/'); ?> '; w3tc_filename_auto_solve(testUrl); } </script> <?php }
function generate() { $pages = array('w3tc_dashboard' => array(__('Dashboard', 'w3-total-cache'), __('Dashboard', 'w3-total-cache'), 'network_show' => true), 'w3tc_general' => array(__('General Settings', 'w3-total-cache'), __('General Settings', 'w3-total-cache'), 'network_show' => false), 'w3tc_pgcache' => array(__('Page Cache', 'w3-total-cache'), __('Page Cache', 'w3-total-cache'), 'network_show' => false), 'w3tc_minify' => array(__('Minify', 'w3-total-cache'), __('Minify', 'w3-total-cache'), 'network_show' => false), 'w3tc_dbcache' => array(__('Database Cache', 'w3-total-cache'), __('Database Cache', 'w3-total-cache'), 'network_show' => false), 'w3tc_objectcache' => array(__('Object Cache', 'w3-total-cache'), __('Object Cache', 'w3-total-cache'), 'network_show' => false)); if (w3_is_pro($this->_config) || w3_is_enterprise($this->_config)) { $pages['w3tc_fragmentcache'] = array(__('Fragment Cache', 'w3-total-cache'), __('Fragment Cache', 'w3-total-cache'), 'network_show' => false); } $pages = array_merge($pages, array('w3tc_browsercache' => array(__('Browser Cache', 'w3-total-cache'), __('Browser Cache', 'w3-total-cache'), 'network_show' => false), 'w3tc_mobile' => array(__('User Agent Groups', 'w3-total-cache'), __('User Agent Groups', 'w3-total-cache'), 'network_show' => false), 'w3tc_referrer' => array(__('Referrer Groups', 'w3-total-cache'), __('Referrer Groups', 'w3-total-cache'), 'network_show' => false), 'w3tc_cdn' => array(__('Content Delivery Network', 'w3-total-cache'), __('<acronym title="Content Delivery Network">CDN</acronym>', 'w3-total-cache'), 'network_show' => $this->_config->get_boolean('cdn.enabled')), 'w3tc_monitoring' => array(__('Monitoring', 'w3-total-cache'), __('Monitoring', 'w3-total-cache'), 'network_show' => false))); $pages_tail = array('w3tc_faq' => array(__('FAQ', 'w3-total-cache'), __('FAQ', 'w3-total-cache'), 'network_show' => true), 'w3tc_support' => array(__('Support', 'w3-total-cache'), __('<span style="color: red;">Support</span>', 'w3-total-cache'), 'network_show' => true), 'w3tc_install' => array(__('Install', 'w3-total-cache'), __('Install', 'w3-total-cache'), 'network_show' => false), 'w3tc_about' => array(__('About', 'w3-total-cache'), __('About', 'w3-total-cache'), 'network_show' => true)); $pages = apply_filters('w3tc_menu', $pages, $this->_config, $this->_config_admin); $pages = array_merge($pages, $pages_tail); add_menu_page(__('Performance', 'w3-total-cache'), __('Performance', 'w3-total-cache'), 'manage_options', 'w3tc_dashboard', '', 'div'); $submenu_pages = array(); foreach ($pages as $slug => $titles) { if ($this->_config_admin->get_boolean('common.visible_by_master_only') && $titles['network_show'] || (!$this->_config_admin->get_boolean('common.visible_by_master_only') || is_super_admin() && (!w3_force_master() || is_network_admin()))) { $submenu_pages[] = add_submenu_page('w3tc_dashboard', $titles[0] . ' | W3 Total Cache', $titles[1], 'manage_options', $slug, array(&$this, 'options')); } } return $submenu_pages; }
/** * Setups actions */ public function admin_init() { if (current_user_can('manage_options')) { /** * @var W3_ConfigCompatibility $config_comp */ $config_comp = w3_instance('W3_ConfigCompatibility'); if ($config_comp->get_old_version() && isset($_GET['page'])) { w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin.php'); if (is_w3tc_admin_page() || isset($GLOBALS['pagenow']) && 'plugins.php' === $GLOBALS['pagenow']) { if (!w3_is_multisite() || !w3_force_master()) { add_action('admin_notices', array($this, 'admin_notices')); } else { add_action('network_admin_notices', array($this, 'admin_notices')); } } $config_comp->setup_settings(); } } }
/** * Checks if can we do cache logic * * @param string $buffer * @return boolean */ function _can_cache2(&$buffer) { /** * Skip if caching is disabled */ if (!$this->_caching) { return false; } /** * Check for database error */ if (w3_is_database_error($buffer)) { $this->cache_reject_reason = 'Database error occurred'; return false; } /** * Check for DONOTCACHEPAGE constant */ if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) { $this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined'; return false; } /** * Check hostname */ if ((!w3_is_multisite() || w3_is_multisite() && !w3_force_master()) && $this->_config->get_boolean('pgcache.check.domain') && w3_get_host() != w3_get_home_domain()) { $this->cache_reject_reason = 'Hostname mismatch'; return false; } /** * Don't cache 404 pages */ if (!$this->_config->get_boolean('pgcache.cache.404') && function_exists('is_404') && is_404()) { $this->cache_reject_reason = 'Page is 404'; return false; } /** * Don't cache homepage */ if (!$this->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') && is_home()) { $this->cache_reject_reason = is_front_page() && is_home() ? 'Page is front page' : 'Page is posts page'; return false; } /** * Don't cache front page */ if ($this->_config->get_boolean('pgcache.reject.front_page') && function_exists('is_front_page') && is_front_page() && !is_home()) { $this->cache_reject_reason = 'Page is front page'; return false; } /** * Don't cache feed */ if (!$this->_config->get_boolean('pgcache.cache.feed') && function_exists('is_feed') && is_feed()) { $this->cache_reject_reason = 'Page is feed'; return false; } /** * Check if page contains dynamic tags */ if ($this->_enhanced_mode && $this->_has_dynamic($buffer)) { $this->cache_reject_reason = 'Page contains dynamic tags (mfunc or mclude) can not be cached in enhanced mode'; return false; } return true; }
</optgroup> <optgroup label="Multiple Servers:"> <option value="memcached"<?php selected($this->_config->get_string('fragmentcache.engine'), 'memcached'); if (!$check_memcached) { ?> disabled="disabled"<?php } ?> >Memcached</option> </optgroup> </select> </td> </tr> <?php if ($this->is_network_and_master() && !w3_force_master()) { ?> <tr> <th>Network policy:</th> <td> <?php $this->checkbox_admin('fragmentcache.configuration_sealed'); ?> Apply the settings above to the entire network.</label> </td> </tr> <?php } ?> </table>
/** * Returns true if config section is sealed * @param string $section * @return boolean */ function w3tc_is_sealed($section) { $config = w3_instance('W3_Config'); $config_master = new W3_Config(true); $config_admin = w3_instance('W3_ConfigAdmin'); if ($config->is_master()) { return false; } if (w3_is_network() && !$config->is_master() && w3_force_master()) { return true; } // browsercache settings change rules, so not available in child settings if ($section == 'browsercache') { return true; } if ($section == 'minify' && !$config_master->get_boolean('minify.enabled')) { return true; } return $config_admin->get_boolean($section . '.configuration_sealed'); }
?> <tr> <th colspan="2"> <?php $this->checkbox('cdn.canonical_header'); ?> Add canonical header</label><br /> <span class="description">Adds canonical <acronym title="Hypertext Transfer Protocol">HTTP</acronym> header to assets files.</span> </th> </tr> <?php } ?> </table> <?php if (!$this->_config_admin->get_boolean('common.visible_by_master_only') || is_super_admin() && (!w3_force_master() || is_network_admin())) { ?> <p class="submit"> <?php echo $this->nonce_field('w3tc'); ?> <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="Save all settings" /> </p> <?php echo $this->postbox_footer(); ?> <?php echo $this->postbox_header('Configuration', '', 'configuration'); ?>
</tr> <?php if ($this->is_network_and_master()) { ?> <tr> <th><?php _e('Use above application name and ID for all sites in network:', 'w3-total-cache'); ?> </th> <td><?php $this->checkbox('newrelic.use_network_wide_id'); ?> </label></td> </tr> <?php if (!w3_force_master()) { ?> <tr> <th><?php _e('Network policy:', 'w3-total-cache'); ?> </th> <td> <?php $this->checkbox_admin('newrelic.configuration_sealed', $this->_config->get_boolean('newrelic.use_network_wide_id')); ?> <?php _e('Apply the settings above to the entire network.', 'w3-total-cache'); ?> </label> </td>
private function _get_config_filename($force_master = false) { if ($this->_blog_id <= 0 || $force_master || w3_force_master()) { return W3TC_CONFIG_DIR . '/master-admin.php'; } return W3TC_CONFIG_DIR . '/' . sprintf('%06d', $this->_blog_id) . '-admin.php'; }
/** * Returns true if config section is sealed * @param string $section * @param W3_Config $config_master * @param W3_ConfigAdmin $config_admin * @return boolean */ private function is_sealed($section, $config_master, $config_admin) { if (w3_get_blog_id() == 0) { return false; } if (w3_is_network() && w3_get_blog_id() != 0 && w3_force_master()) { return true; } // browsercache settings change rules, so not available in child settings if ($section == 'browsercache') { return true; } if ($section == 'minify' && !$config_master->get_boolean('minify.enabled')) { return true; } return $config_admin->get_boolean($section . '.configuration_sealed'); }
private function _get_config_filename($forced_preview = null) { $preview = is_null($forced_preview) ? $this->_preview : $forced_preview; $postfix = ($preview ? '-preview' : '') . '.php'; if ($this->_blog_id <= 0 || w3_force_master()) { return W3TC_CACHE_CONFIG_DIR . '/master' . $postfix; } return W3TC_CACHE_CONFIG_DIR . '/' . sprintf('%06d', $this->_blog_id) . $postfix; }
public static function get_config_filename() { $force_master = false; if (w3_force_master()) { $force_master = true; } $postfix = '.php'; if (w3_get_blog_id() <= 0 || $force_master) { return W3TC_CONFIG_DIR . '/master' . $postfix; } return W3TC_CONFIG_DIR . '/' . sprintf('%06d', w3_get_blog_id()) . $postfix; }
/** * Returns true if config section is sealed * @param string $section * @return boolean */ protected function is_sealed($section) { if ($this->is_master()) { return false; } if (w3_is_network() && !$this->is_master() && w3_force_master()) { return true; } // browsercache settings change rules, so not available in child settings if ($section == 'browsercache') { return true; } if ($section == 'minify' && !$this->_config_master->get_boolean('minify.enabled')) { return true; } return $this->_config_admin->get_boolean($section . '.configuration_sealed'); }
?> "><?php _e('Visit extension site', 'w3-total-cache'); ?> </a> </div> </td> </tr> <?php do_action("w3tc_extension_after_row", $extension); ?> <?php do_action("w3tc_extension_after_row-{$extension}"); ?> <?php if (is_network_admin() && !w3_force_master()) { ?> <tr> <th></th> <th><?php _e('Network policy:', 'w3-total-cache'); ?> </th> <td> <?php $this->checkbox_admin_extensions("extensions.configuration_sealed", $extension); ?> <?php printf(__('Apply the %s settings to the entire network.', 'w3-total-cache'), $meta['name']); ?> </label>
/** * Options save action * * @return void */ function action_save_options() { /** * Redirect params */ $params = array(); /** * Store error message regarding permalink not enabled */ $redirect_permalink_error = ''; /** * Read config * We should use new instance of WP_Config object here */ @($config = new W3_Config()); $this->read_request($config); $config_admin = new W3_ConfigAdmin(); $this->read_request($config_admin); /** * General tab */ if ($this->_page == 'w3tc_general') { $file_nfs = W3_Request::get_boolean('file_nfs'); $file_locking = W3_Request::get_boolean('file_locking'); $config->set('pgcache.file.nfs', $file_nfs); $config->set('minify.file.nfs', $file_nfs); $config->set('dbcache.file.locking', $file_locking); $config->set('objectcache.file.locking', $file_locking); $config->set('pgcache.file.locking', $file_locking); $config->set('minify.file.locking', $file_locking); if ($this->is_network_and_master()) { if ($this->_config->get_boolean('common.force_master') !== $config->get_boolean('common.force_master') || !w3_force_master() && $this->_config->get_boolean('common.force_master') && $config->get_boolean('common.force_master') || w3_force_master() && !$this->_config->get_boolean('common.force_master') && !$config->get_boolean('common.force_master')) { $blog_home_url = w3_generate_request_uri(); $blogmap_file = w3_blogmap_filename($blog_home_url); @unlink($blogmap_file); $blogmap_dir = dirname(W3TC_CACHE_BLOGMAP_FILENAME) . '/' . basename(W3TC_CACHE_BLOGMAP_FILENAME, '.php') . '/'; if (is_dir($blogmap_dir)) { w3_rmdir($blogmap_dir); } } if ($config->get_boolean('common.force_master')) { $config_admin->set('common.visible_by_master_only', true); } } /** * Check permalinks for page cache */ if ($config->get_boolean('pgcache.enabled') && $config->get_string('pgcache.engine') == 'file_generic' && !get_option('permalink_structure')) { $config->set('pgcache.enabled', false); $redirect_permalink_error = 'fancy_permalinks_disabled_pgcache'; } $w3_cloudflare = w3_instance('W3_CloudFlare'); $w3_cloudflare->reset_settings_cache(); if ($config->get_boolean('cloudflare.enabled') && $w3_cloudflare->minify_enabled() && $config->get_boolean('minify.enabled')) { $config->set('minify.enabled', false); } /** * Get New Relic application id */ if ($config->get_boolean('newrelic.enabled')) { $method = W3_Request::get_string('application_id_method'); $newrelic_prefix = ''; if (w3_is_network() && w3_get_blog_id() != 0) { $newrelic_prefix = $this->_config->get_string('newrelic.appname_prefix'); } if (($newrelic_api_key = $config->get_string('newrelic.api_key')) && !$config->get_string('newrelic.account_id')) { $nerser = w3_instance('W3_NewRelicService'); $account_id = $nerser->get_account_id($newrelic_api_key); $config->set('newrelic.account_id', $account_id); } if ($method == 'dropdown' && $config->get_string('newrelic.application_id')) { $application_id = $config->get_string('newrelic.application_id'); if ($config->get_string('newrelic.api_key') && $config->get_string('newrelic.account_id')) { w3_require_once(W3TC_LIB_W3_DIR . '/NewRelicService.php'); $nerser = new W3_NewRelicService($config->get_string('newrelic.api_key'), $config->get_string('newrelic.account_id')); $appname = $nerser->get_application_name($application_id); $config->set('newrelic.appname', $appname); } } else { if ($method == 'manual' && $config->get_string('newrelic.appname')) { if ($newrelic_prefix != '' && strpos($config->get_string('newrelic.appname'), $newrelic_prefix) === false) { $application_name = $newrelic_prefix . $config->get_string('newrelic.appname'); $config->set('newrelic.appname', $application_name); } else { $application_name = $config->get_string('newrelic.appname'); } if ($config->get_string('newrelic.api_key') && $config->get_string('newrelic.account_id')) { w3_require_once(W3TC_LIB_W3_DIR . '/NewRelicService.php'); $nerser = new W3_NewRelicService($config->get_string('newrelic.api_key'), $config->get_string('newrelic.account_id')); $application_id = $nerser->get_application_id($application_name); if ($application_id) { $config->set('newrelic.application_id', $application_id); } } } } } } /** * Minify tab */ if ($this->_page == 'w3tc_minify' && !$this->_config->get_boolean('minify.auto')) { $js_groups = array(); $css_groups = array(); $js_files = W3_Request::get_array('js_files'); $css_files = W3_Request::get_array('css_files'); foreach ($js_files as $theme => $templates) { foreach ($templates as $template => $locations) { foreach ((array) $locations as $location => $types) { foreach ((array) $types as $type => $files) { foreach ((array) $files as $file) { if (!empty($file)) { $js_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file); } } } } } } foreach ($css_files as $theme => $templates) { foreach ($templates as $template => $locations) { foreach ((array) $locations as $location => $files) { foreach ((array) $files as $file) { if (!empty($file)) { $css_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file); } } } } } $config->set('minify.js.groups', $js_groups); $config->set('minify.css.groups', $css_groups); $js_theme = W3_Request::get_string('js_theme'); $css_theme = W3_Request::get_string('css_theme'); $params = array_merge($params, array('js_theme' => $js_theme, 'css_theme' => $css_theme)); } /** * Browser Cache tab */ if ($this->_page == 'w3tc_browsercache') { if ($config->get_boolean('browsercache.enabled') && $config->get_boolean('browsercache.no404wp') && !get_option('permalink_structure')) { $config->set('browsercache.no404wp', false); $redirect_permalink_error = 'fancy_permalinks_disabled_browsercache'; } $config->set('browsercache.timestamp', time()); } /** * Mobile tab */ if ($this->_page == 'w3tc_mobile') { $groups = W3_Request::get_array('mobile_groups'); $mobile_groups = array(); $cached_mobile_groups = array(); foreach ($groups as $group => $group_config) { $group = strtolower($group); $group = preg_replace('~[^0-9a-z_]+~', '_', $group); $group = trim($group, '_'); if ($group) { $theme = isset($group_config['theme']) ? trim($group_config['theme']) : 'default'; $enabled = isset($group_config['enabled']) ? (bool) $group_config['enabled'] : true; $redirect = isset($group_config['redirect']) ? trim($group_config['redirect']) : ''; $agents = isset($group_config['agents']) ? explode("\r\n", trim($group_config['agents'])) : array(); $mobile_groups[$group] = array('theme' => $theme, 'enabled' => $enabled, 'redirect' => $redirect, 'agents' => $agents); $cached_mobile_groups[$group] = $agents; } } /** * Allow plugins modify WPSC mobile groups */ $cached_mobile_groups = apply_filters('cached_mobile_groups', $cached_mobile_groups); /** * Merge existent and delete removed groups */ foreach ($mobile_groups as $group => $group_config) { if (isset($cached_mobile_groups[$group])) { $mobile_groups[$group]['agents'] = (array) $cached_mobile_groups[$group]; } else { unset($mobile_groups[$group]); } } /** * Add new groups */ foreach ($cached_mobile_groups as $group => $agents) { if (!isset($mobile_groups[$group])) { $mobile_groups[$group] = array('theme' => '', 'enabled' => true, 'redirect' => '', 'agents' => $agents); } } /** * Allow plugins modify W3TC mobile groups */ $mobile_groups = apply_filters('w3tc_mobile_groups', $mobile_groups); /** * Sanitize mobile groups */ foreach ($mobile_groups as $group => $group_config) { $mobile_groups[$group] = array_merge(array('theme' => '', 'enabled' => true, 'redirect' => '', 'agents' => array()), $group_config); $mobile_groups[$group]['agents'] = array_unique($mobile_groups[$group]['agents']); $mobile_groups[$group]['agents'] = array_map('strtolower', $mobile_groups[$group]['agents']); sort($mobile_groups[$group]['agents']); } $enable_mobile = false; foreach ($mobile_groups as $group => $group_config) { if ($group_config['enabled']) { $enable_mobile = true; break; } } $config->set('mobile.enabled', $enable_mobile); $config->set('mobile.rgroups', $mobile_groups); } /** * Referrer tab */ if ($this->_page == 'w3tc_referrer') { $groups = W3_Request::get_array('referrer_groups'); $referrer_groups = array(); foreach ($groups as $group => $group_config) { $group = strtolower($group); $group = preg_replace('~[^0-9a-z_]+~', '_', $group); $group = trim($group, '_'); if ($group) { $theme = isset($group_config['theme']) ? trim($group_config['theme']) : 'default'; $enabled = isset($group_config['enabled']) ? (bool) $group_config['enabled'] : true; $redirect = isset($group_config['redirect']) ? trim($group_config['redirect']) : ''; $referrers = isset($group_config['referrers']) ? explode("\r\n", trim($group_config['referrers'])) : array(); $referrer_groups[$group] = array('theme' => $theme, 'enabled' => $enabled, 'redirect' => $redirect, 'referrers' => $referrers); } } /** * Allow plugins modify W3TC referrer groups */ $referrer_groups = apply_filters('w3tc_referrer_groups', $referrer_groups); /** * Sanitize mobile groups */ foreach ($referrer_groups as $group => $group_config) { $referrer_groups[$group] = array_merge(array('theme' => '', 'enabled' => true, 'redirect' => '', 'referrers' => array()), $group_config); $referrer_groups[$group]['referrers'] = array_unique($referrer_groups[$group]['referrers']); $referrer_groups[$group]['referrers'] = array_map('strtolower', $referrer_groups[$group]['referrers']); sort($referrer_groups[$group]['referrers']); } $enable_referrer = false; foreach ($referrer_groups as $group => $group_config) { if ($group_config['enabled']) { $enable_referrer = true; break; } } $config->set('referrer.enabled', $enable_referrer); $config->set('referrer.rgroups', $referrer_groups); } /** * CDN tab */ if ($this->_page == 'w3tc_cdn') { $cdn_cnames = W3_Request::get_array('cdn_cnames'); $cdn_domains = array(); foreach ($cdn_cnames as $cdn_cname) { $cdn_cname = trim($cdn_cname); /** * Auto expand wildcard domain to 10 subdomains */ $matches = null; if (preg_match('~^\\*\\.(.*)$~', $cdn_cname, $matches)) { $cdn_domains = array(); for ($i = 1; $i <= 10; $i++) { $cdn_domains[] = sprintf('cdn%d.%s', $i, $matches[1]); } break; } if ($cdn_cname) { $cdn_domains[] = $cdn_cname; } } switch ($this->_config->get_string('cdn.engine')) { case 'ftp': $config->set('cdn.ftp.domain', $cdn_domains); break; case 's3': $config->set('cdn.s3.cname', $cdn_domains); break; case 'cf': $config->set('cdn.cf.cname', $cdn_domains); break; case 'cf2': $config->set('cdn.cf2.cname', $cdn_domains); break; case 'rscf': $config->set('cdn.rscf.cname', $cdn_domains); break; case 'azure': $config->set('cdn.azure.cname', $cdn_domains); break; case 'mirror': $config->set('cdn.mirror.domain', $cdn_domains); break; case 'netdna': $config->set('cdn.netdna.domain', $cdn_domains); break; case 'cotendo': $config->set('cdn.cotendo.domain', $cdn_domains); break; case 'edgecast': $config->set('cdn.edgecast.domain', $cdn_domains); break; case 'att': $config->set('cdn.att.domain', $cdn_domains); break; case 'akamai': $config->set('cdn.akamai.domain', $cdn_domains); break; } } $this->config_save($config, $config_admin); switch ($this->_page) { case 'w3tc_cdn': /** * Handle Set Cookie Domain */ $set_cookie_domain_old = W3_Request::get_boolean('set_cookie_domain_old'); $set_cookie_domain_new = W3_Request::get_boolean('set_cookie_domain_new'); if ($set_cookie_domain_old != $set_cookie_domain_new) { if ($set_cookie_domain_new) { if (!$this->enable_cookie_domain()) { $this->redirect(array_merge($params, array('w3tc_error' => 'enable_cookie_domain'))); } } else { if (!$this->disable_cookie_domain()) { $this->redirect(array_merge($params, array('w3tc_error' => 'disable_cookie_domain'))); } } } break; case 'w3tc_general': /** * Handle CloudFlare changes */ if ($this->_config->get_boolean('cloudflare.enabled') && (w3_get_blog_id() == 0 || w3_get_blog_id() != 0 && !$this->is_sealed('cloudflare'))) { /** * @var $w3_cloudflare W3_CloudFlare */ $w3_cloudflare = w3_instance('W3_CloudFlare'); W3_CloudFlare::clear_last_error(''); $cf_values = W3_Request::get_as_array('cloudflare_'); if (!$w3_cloudflare->save_settings($cf_values)) { $this->redirect(array_merge($params, array('w3tc_error' => 'cloudflare_api_request'))); } } break; } $this->_notes[] = 'config_save'; if ($redirect_permalink_error) { $this->redirect(array('w3tc_error' => $redirect_permalink_error, 'w3tc_note' => 'config_save')); } $this->redirect_with_custom_messages($params); }