<?php /** * W3 Total Cache Minify module */ if (!defined('ABSPATH')) { require_once dirname(__FILE__) . '/../../../wp-load.php'; } if (!defined('W3TC_DIR')) { define('W3TC_DIR', realpath(dirname(__FILE__) . '/../plugins/w3-total-cache')); } if (!is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/inc/define.php')) { die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', dirname(__FILE__))); } require_once W3TC_DIR . '/inc/define.php'; require_once W3TC_DIR . '/lib/W3/Minify.php'; $w3_minify =& W3_Minify::instance(); $w3_minify->process();
/** * Formats custom URL * * @param array $files * @param string $type * @return string */ function format_url_custom($files, $type) { require_once W3TC_LIB_W3_DIR . '/Minify.php'; $w3_minify =& W3_Minify::instance(); $w3_minify->set_custom_files($files, $type); $hash = $w3_minify->get_custom_files_hash($files); $id = $w3_minify->get_id_custom($hash, $type); $site_url_ssl = w3_get_site_url_ssl(); if ($this->_config->get_boolean('minify.rewrite')) { $url = sprintf('%s/%s/%s.%s.%s', $site_url_ssl, W3TC_CONTENT_MINIFY_DIR_NAME, $hash, $id, $type); } else { $url = sprintf('%s/%s/index.php?file=%s.%s.%s', $site_url_ssl, W3TC_CONTENT_MINIFY_DIR_NAME, $hash, $id, $type); } return $url; }
/** * Flush minify cache * * @return void */ function flush_minify() { if (W3TC_PHP5) { require_once W3TC_LIB_W3_DIR . '/Minify.php'; $w3_minify =& W3_Minify::instance(); $w3_minify->flush(); } }
/** * Shortcut for minify cache flush * * @return boolean */ function w3tc_minify_flush() { require_once W3TC_LIB_W3_DIR . '/Minify.php'; $w3_minify =& W3_Minify::instance(); return $w3_minify->flush(); }
/** * Returns debug info */ function get_debug_info() { $group = $this->get_group(); $debug_info = "<!-- W3 Total Cache: Minify debug info:\r\n"; $debug_info .= sprintf("%s%s\r\n", str_pad('Engine: ', 20), w3_get_engine_name($this->_config->get_string('minify.engine'))); $debug_info .= sprintf("%s%s\r\n", str_pad('Group: ', 20), $group); require_once W3TC_LIB_W3_DIR . '/Minify.php'; $w3_minify =& W3_Minify::instance(); $css_groups = $w3_minify->get_groups($group, 'css'); if (count($css_groups)) { $debug_info .= "Stylesheet info:\r\n"; $debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Location', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path'); foreach ($css_groups as $css_group => $css_files) { foreach ($css_files as $css_file => $css_file_path) { if (is_a($css_file_path, 'Minify_Source')) { $css_file_path = $css_file_path->filepath; $css_file_info = sprintf('%s (%s)', $css_file, $css_file_path); } else { $css_file_info = $css_file; $css_file_path = ABSPATH . ltrim($css_file_path, '/\\'); } $debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($css_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($css_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($css_file_path), 12, ' ', STR_PAD_LEFT), $css_file_info); } } } $js_groups = $w3_minify->get_groups($group, 'js'); if (count($js_groups)) { $debug_info .= "JavaScript info:\r\n"; $debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad('Location', 15, ' ', STR_PAD_BOTH), str_pad('Last modified', 19, ' ', STR_PAD_BOTH), str_pad('Size', 12, ' ', STR_PAD_LEFT), 'Path'); foreach ($js_groups as $js_group => $js_files) { foreach ($js_files as $js_file => $js_file_path) { if (is_a($js_file_path, 'Minify_Source')) { $js_file_path = $js_file_path->filepath; $js_file_info = sprintf('%s (%s)', $js_file, $js_file_path); } else { $js_file_path = $js_file_info = ABSPATH . ltrim($js_file, '/\\'); } $debug_info .= sprintf("%s | %s | % s | %s\r\n", str_pad($js_group, 15, ' ', STR_PAD_BOTH), str_pad(date('Y-m-d H:i:s', filemtime($js_file_path)), 19, ' ', STR_PAD_BOTH), str_pad(filesize($js_file_path), 12, ' ', STR_PAD_LEFT), $js_file_info); } } } $debug_info .= '-->'; return $debug_info; }