/** * Returns themes array * * @return array */ function w3_get_themes() { $themes = array(); $wp_themes = w3tc_get_themes(); foreach ($wp_themes as $wp_theme) { $theme_key = w3_get_theme_key($wp_theme['Theme Root'], $wp_theme['Template'], $wp_theme['Stylesheet']); $themes[$theme_key] = $wp_theme['Name']; } return $themes; }
/** * Returns current theme * * @return string */ function get_theme() { static $theme = null; if ($theme === null) { $theme = w3_get_theme_key(get_theme_root(), get_template(), get_stylesheet()); } return $theme; }
/** * 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; }