aboutsummaryrefslogtreecommitdiff
path: root/mod/minify/start.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:11:12 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:11:12 -0300
commit656f816ee6f56747ed7770dbd6b67305676f654a (patch)
tree5cc3560ee5c6b60d07365940355dda241c0c88df /mod/minify/start.php
parent7d9fff84991467dfe4d28f206663f50e38dbbc6d (diff)
parentd42607998482e36865c1d8a443f92a457f6b2f3b (diff)
downloadelgg-656f816ee6f56747ed7770dbd6b67305676f654a.tar.gz
elgg-656f816ee6f56747ed7770dbd6b67305676f654a.tar.bz2
Merge commit 'd42607998482e36865c1d8a443f92a457f6b2f3b' as 'mod/minify'
Diffstat (limited to 'mod/minify/start.php')
-rw-r--r--mod/minify/start.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/mod/minify/start.php b/mod/minify/start.php
new file mode 100644
index 000000000..33ef6d4f3
--- /dev/null
+++ b/mod/minify/start.php
@@ -0,0 +1,22 @@
+<?php
+
+function minify_init() {
+ //make sure this runs after everyone else is done
+ elgg_register_plugin_hook_handler('view', 'all', 'minify_views', 1000);
+}
+
+function minify_views($hook, $type, $content, $params) {
+ $view = $params['view'];
+
+ if (preg_match("/^js\//", $view)) {
+ if (include_once dirname(__FILE__) . '/vendors/min/lib/JSMin.php') {
+ return JSMin::minify($content);
+ }
+ } elseif (preg_match("/^css\//", $view)) {
+ if (include_once dirname(__FILE__) . '/vendors/min/lib/CSS.php') {
+ return Minify_CSS::minify($content);
+ }
+ }
+}
+
+elgg_register_event_handler('init', 'system', 'minify_init');