/** * Returns theme recommendations * * @param string $theme_name * @return array */ function get_theme_recommendations($theme_name) { $urls = $this->get_theme_urls($theme_name); $js_groups = array(); $css_groups = array(); @set_time_limit($this->_config->get_integer('timelimit.minify_recommendations')); foreach ($urls as $template => $url) { /** * Append theme identifier */ $url .= (strstr($url, '?') !== false ? '&' : '?') . 'w3tc_theme=' . urlencode($theme_name); /** * If preview mode enabled append w3tc_preview */ if (w3_is_preview_config()) { $url .= '&w3tc_preview=1'; } /** * Get page contents * Don't check response code for 404 template */ $content = w3_http_get($url, null, $template != '404'); if ($content) { $js_files = $this->get_recommendations_js($content); $css_files = $this->get_recommendations_css($content); $js_groups[$template] = $js_files; $css_groups[$template] = $css_files; } } $js_groups = $this->_get_theme_recommendations($js_groups); $css_groups = $this->_get_theme_recommendations($css_groups); $recommendations = array($js_groups, $css_groups); return $recommendations; }
/** * Retuns true if preview settings active * * @return boolean */ function w3_is_preview_mode() { return w3_is_preview_config() && (defined('WP_ADMIN') || isset($_REQUEST['w3tc_preview']) || isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'w3tc_preview') !== false); }
/** * Returns theme recommendations * * @param string $theme_name * @return array */ function get_theme_recommendations($theme_name) { $urls = $this->get_theme_urls($theme_name); $js_groups = array(); $css_groups = array(); @set_time_limit($this->_config->get_integer('timelimit.minify_recommendations')); foreach ($urls as $template => $url) { /** * Append theme identifier */ $url .= (strstr($url, '?') !== false ? '&' : '?') . 'w3tc_theme=' . urlencode($theme_name); /** * If preview mode enabled append w3tc_preview */ if (w3_is_preview_config()) { $url .= '&w3tc_preview=1'; } /** * Get page contents */ $response = w3_http_get($url); if (!is_nxt_error($response) && ($response['response']['code'] == 200 || $response['response']['code'] == 404 && $template == '404')) { $js_files = $this->get_recommendations_js($response['body']); $css_files = $this->get_recommendations_css($response['body']); $js_groups[$template] = $js_files; $css_groups[$template] = $css_files; } } $js_groups = $this->get_theme_recommendations_by_groups($js_groups); $css_groups = $this->get_theme_recommendations_by_groups($css_groups); $recommendations = array($js_groups, $css_groups); return $recommendations; }