/** * Method for template_post_parse hook * * @param string Parsed template string * @param bool Whether is a sub-template or not * @param string Site ID * @return string Template string, possibly minified */ public function template_post_parse($template, $sub, $site_id) { // play nice with others if (isset($this->EE->extensions->last_call) && $this->EE->extensions->last_call) { $template = $this->EE->extensions->last_call; } // do nothing if not final template if ($sub !== FALSE) { return $template; } // see if we need to post-render any plugin methods if (isset($this->cache['template_post_parse'])) { if (!class_exists('Minimee')) { include_once PATH_THIRD . 'minimee/pi.minimee.php'; } // create a new instance of Minimee each time to guarantee defaults $m = new Minimee(); // save our TMPL values to put back into place once finished $tagparams = $this->EE->TMPL->tagparams; // loop through & call each method foreach ($this->cache['template_post_parse'] as $needle => $tag) { Minimee_helper::log('Calling Minimee::display("' . $tag['method'] . '") during template_post_parse: ' . serialize($tag['tagparams']), 3); $this->EE->TMPL->tagparams = $tag['tagparams']; // our second parameter tells Minimee we are calling from template_post_parse $out = $m->display($tag['method'], TRUE); // replace our needle with output $template = str_replace(LD . $needle . RD, $out, $template); // reset Minimee for next loop $m->reset(); } // put things back into place $this->EE->TMPL->tagparams = $tagparams; } // do nothing if not (likely) html! if (!preg_match('/webpage|static/i', $this->EE->TMPL->template_type)) { return $template; } // Are we configured to run through HTML minifier? if ($this->config->is_no('minify_html')) { Minimee_helper::log('HTML minification is disabled.', 3); return $template; } // is Minimee nonetheless disabled? if ($this->config->is_yes('disable')) { Minimee_helper::log('HTML minification aborted because Minimee has been disabled completely.', 3); return $template; } // we've made it this far, so... Minimee_helper::log('Running HTML minification.', 3); Minimee_helper::library('html'); // run css & js minification? $opts = array(); if ($this->config->is_yes('minify_css')) { $opts['cssMinifier'] = array('Minify_CSS', 'minify'); } if ($this->config->is_yes('minify_js')) { $opts['jsMinifier'] = array('JSMin', 'minify'); } return Minify_HTML::minify($template, $opts); }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } // our Minimee_lib require_once PATH_THIRD . 'minimee/classes/Minimee_lib.php'; $plugin_info = array('pi_name' => MINIMEE_NAME, 'pi_version' => MINIMEE_VER, 'pi_author' => MINIMEE_AUTHOR, 'pi_author_url' => MINIMEE_DOCS, 'pi_description' => MINIMEE_DESC, 'pi_usage' => Minimee::usage()); /** * ExpressionEngine - by EllisLab * * @package ExpressionEngine * @author ExpressionEngine Dev Team * @copyright Copyright (c) 2003 - 2011, EllisLab, Inc. * @license http://expressionengine.com/user_guide/license.html * @link http://expressionengine.com * @since Version 2.0 * @filesource */ // ------------------------------------------------------------------------ /** * Minimee: minimize & combine your CSS and JS files. Minify your HTML. For EE2 only. * @author John D Wells <http://johndwells.com> * @license http://www.opensource.org/licenses/bsd-license.php BSD license * @link http://johndwells.com/software/minimee */ class Minimee { /** * Reference to our cache */
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require_once PATH_THIRD . 'minimee/config.php'; $plugin_info = array( 'pi_name' => MIMIMEE_NAME, 'pi_version' => MIMIMEE_VER, 'pi_author' => MIMIMEE_AUTHOR, 'pi_author_url' => MIMIMEE_DOCS, 'pi_description' => MIMIMEE_DESC, 'pi_usage' => Minimee::usage() ); /** * Minimee: minimize & combine your CSS and JS files. For EE2 only. * @author John D Wells <http://johndwells.com> * @license http://www.opensource.org/licenses/bsd-license.php BSD license * @link http://johndwells.com/software/minimee */ class Minimee { /* config - required */ public $cache_path; public $cache_url; /* config - optional */ public $base_path; public $base_url; public $debug; public $disable;