/** * creates link to style.css */ function thematic_create_stylesheet() { global $my_shortname; $hhUrl = stripslashes(get_option($my_shortname . '_hh_style_url')); $mainUrl = stripslashes(get_option($my_shortname . '_main_style_url')); $hh = stripslashes(get_option($my_shortname . '_handheld')); $minify = stripslashes(get_option($my_shortname . '_minify')); $content .= "<!-- style links " . ($minify == 'css' || $minify == 'css and js' ? 'minifed ' : 'non minifed ') . "-->\n"; if (($minify == 'css' || $minify == 'css and js') && function_exists('w3tc_styles')) { $w3_plugin_minify =& W3_Plugin_Minify::instance(); $w3_plugin_minify->printed_styles[] = $location; $content .= $w3_plugin_minify->get_styles($location, $group); if ($hh == 'true') { $content .= "\n<link rel=\"stylesheet\" media=\"handheld\" type=\"text/css\" href=\""; $content .= !empty($hhUrl) ? $hhUrl : get_stylesheet_directory_uri() . "/library/css/handheld.css"; $content .= "\">\n"; } } elseif (($minify == 'css' || $minify == 'cssjs') && function_exists('wp_minify')) { } else { $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\""; $content .= !empty($mainUrl) ? $mainUrl : get_bloginfo('stylesheet_url'); $content .= "\">\n"; if ($hh == 'true') { $content .= "<link rel=\"stylesheet\" media=\"handheld\" type=\"text/css\" href=\""; $content .= !empty($hhUrl) ? $hhUrl : get_stylesheet_directory_uri() . "/library/css/handheld.css"; $content .= "\">\n"; } } $content .= "\n"; echo apply_filters('thematic_create_stylesheet', $content); }
/** * Output buffering callback * * @param string $buffer * @return string */ function ob_callback(&$buffer) { global $wpdb; if ($buffer != '' && w3_is_xml($buffer)) { if (w3_is_database_error($buffer)) { @header('HTTP/1.1 503 Service Unavailable'); } else { /** * Replace links for preview mode */ if (w3_is_preview_mode() && isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != W3TC_POWERED_BY) { $domain_url_regexp = w3_get_domain_url_regexp(); $buffer = preg_replace_callback('~(href|src|action)=([\'"])(' . $domain_url_regexp . ')?(/[^\'"]*)~', array(&$this, 'link_replace_callback'), $buffer); } /** * Add footer comment */ $date = date_i18n('Y-m-d H:i:s'); $host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'; if ($this->is_supported()) { $buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date); } else { $strings = array(); if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) { require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php'; $w3_plugin_minify =& W3_Plugin_Minify::instance(); $strings[] = sprintf("Minified using %s%s", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : ''); } if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) { require_once W3TC_LIB_W3_DIR . '/PgCache.php'; $w3_pgcache =& W3_PgCache::instance(); $strings[] = sprintf("Page Caching using %s%s", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : ''); } if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug') && is_a($wpdb, 'W3_Db')) { $append = is_user_logged_in() ? ' (user is logged in)' : ''; if ($wpdb->query_hits) { $strings[] = sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append); } else { $strings[] = sprintf("Database Caching using %s%s", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append); } } if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) { require_once W3TC_LIB_W3_DIR . '/ObjectCache.php'; $w3_objectcache =& W3_ObjectCache::instance(); $strings[] = sprintf("Object Caching %d/%d objects using %s", $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine'))); } if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) { require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php'; $w3_plugin_cdn =& W3_Plugin_Cdn::instance(); $cdn =& $w3_plugin_cdn->get_cdn(); $via = $cdn->get_via(); $strings[] = sprintf("Content Delivery Network via %s%s", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : ''); } $buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n"; if (count($strings)) { $buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n"; } $buffer .= sprintf("\r\nServed from: %s @ %s -->", w3_escape_comment($host), $date); } } } return $buffer; }
/** * Prints style tag for custom styles * * @param string|array $files * @param boolean $import * @return void */ function w3tc_minify_style_custom($files, $import = false) { require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php'; $w3_plugin_minify =& W3_Plugin_Minify::instance(); echo $w3_plugin_minify->get_style_custom($files, $import); }
/** * Prints link for custom styles * * @param string|array $files * @param boolean $import */ function w3tc_custom_style($files, $import = false) { $w3_plugin_minify =& W3_Plugin_Minify::instance(); echo $w3_plugin_minify->get_custom_style($files, $import); }
/** * make this work with either minify group config. (gallery for example will be a particular group of js just used on those pages) * the wp interface minify list * could also be set to auto minify - that works since the styles since they are in head * css is a breeze to min * // make this an option jquery might be bundled in one file some dislike google hosted api // but if google cdn then need to add before this script // and result make this file load other api etc swfobject */ function thematic_script_foot() { global $my_shortname; $jsfoot = stripslashes(get_option($my_shortname . '_jsfoot')); $jqversion = stripslashes(get_option($my_shortname . '_jquery_version')); $minify = stripslashes(get_option($my_shortname . '_minify')); if (empty($jsfoot) || $jsfoot == 'true') { echo themeatic_script_setup(false); echo "<!-- script foot -->"; if (class_exists('W3_Plugin_Minify', false)) { $w3_plugin_minify =& W3_Plugin_Minify::instance(); $w3_plugin_minify->printed_scripts[] = $location; if (($minify == 'js' || $minify == 'css and js') && function_exists('w3tc_styles')) { echo $w3_plugin_minify->get_scripts('include-footer', null); echo $w3_plugin_minify->get_scripts('include-footer-nb', null); } } elseif (class_exists('WP_Minify')) { } thematic_ifieblock(); thematic_googleanalytics(); thematic_yahooprofiler(); } }
/** * Exports min files to CDN * * @return array */ function get_files_minify() { $files = array(); if (W3TC_PHP5 && $this->_config->get_boolean('minify.rewrite') && (!$this->_config->get_boolean('minify.auto') || w3_is_cdn_mirror($this->_config->get_string('cdn.engine')))) { require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php'; $minify =& W3_Plugin_Minify::instance(); $document_root = w3_get_document_root(); $site_root = w3_get_site_root(); $minify_root = w3_path(W3TC_CACHE_FILE_MINIFY_DIR); $minify_path = ltrim(str_replace($site_root, rtrim(w3_get_site_path(), '/'), $minify_root), '/'); $urls = $minify->get_urls(); if ($this->_config->get_string('minify.engine') == 'file') { foreach ($urls as $url) { w3_http_get($url); } $files = $this->search_files($minify_root, $minify_path, '*.css;*.js'); } else { foreach ($urls as $url) { $file = w3_normalize_file_minify($url); $file = w3_translate_file($file); if (!w3_is_url($file)) { $file = $document_root . '/' . $file; $file = ltrim(str_replace($minify_root, '', $file), '/'); $dir = dirname($file); if ($dir) { w3_mkdir($dir, 0777, $minify_root); } if (w3_download($url, $minify_root . '/' . $file) !== false) { $files[] = $minify_path . '/' . $file; } } } } } return $files; }
/** * Exports min files to CDN */ function get_files_minify() { $files = array(); if (W3TC_PHP5) { require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php'; $minify =& W3_Plugin_Minify::instance(); $urls = $minify->get_urls(); foreach ($urls as $url) { $file = basename($url); if (w3_download($url, W3TC_CONTENT_MINIFY_DIR . '/' . $file) !== false) { $files[] = W3TC_CONTENT_MINIFY_DIR_NAME . '/' . $file; } } } return $files; }
/** * Output buffering callback * * @param string $buffer * @return string */ function ob_callback($buffer) { global $wpdb; if ($buffer != '' && w3_is_xml($buffer)) { $date = date('Y-m-d H:i:s'); $host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'; if ($this->is_supported()) { $buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", $host, $date); } else { $buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n\r\n"; if ($this->_config->get_boolean('minify.enabled')) { require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php'; $w3_plugin_minify =& W3_Plugin_Minify::instance(); $buffer .= sprintf("Minified using %s%s\r\n", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : ''); } if ($this->_config->get_boolean('pgcache.enabled')) { require_once W3TC_LIB_W3_DIR . '/PgCache.php'; $w3_pgcache =& W3_PgCache::instance(); $buffer .= sprintf("Page Caching using %s%s\r\n", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : ''); } if ($this->_config->get_boolean('dbcache.enabled') && is_a($wpdb, 'W3_Db')) { $append = is_user_logged_in() ? ' (user is logged in)' : ''; if ($wpdb->query_hits) { $buffer .= sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s\r\n", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append); } else { $buffer .= sprintf("Database Caching using %s%s\r\n", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append); } } if ($this->_config->get_boolean('cdn.enabled')) { require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php'; $w3_plugin_cdn =& W3_Plugin_Cdn::instance(); $cdn =& $w3_plugin_cdn->get_cdn(); $via = $cdn->get_via(); $buffer .= sprintf("Content Delivery Network via %s%s\r\n", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : ''); } $buffer .= sprintf("\r\nServed from: %s @ %s -->", $host, $date); } } return $buffer; }