PluginProbe
Autoptimize / 1.6.4
Autoptimize v1.6.4
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
autoptimize / classes / autoptimizeHTML.php

autoptimizeHTML.php in Autoptimize 1.6.4, at classes/autoptimizeHTML.php

59 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class autoptimizeHTML extends autoptimizeBase
4 {
5 private $keepcomments = false;
6
7 //Does nothing
8 public function read($options)
9 {
10 //Remove the HTML comments?
11 $this->keepcomments = (bool) $options['keepcomments'];
12
13 //Nothing to read for HTML
14 return true;
15 }
16
17 //Joins and optimizes CSS
18 public function minify()
19 {
20 if(class_exists('Minify_HTML'))
21 {
22 // Minify html
23 // but don't remove comment-blocks needed by WP Super Cache (& W3 Total Cache)
24 if ( ($this->keepcomments===false) && (preg_match( '/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $this->content ))) {
25 $this->content = preg_replace('#(<!--mclude .*<!--/mclude-->)#ise','\'%%MFUNC%%\'.base64_encode("$0").\'%%MFUNC%%\'', $this->content);
26 $this->content = preg_replace('#(<!--mfunc.*<!--/mfunc-->)#ise','\'%%MFUNC%%\'.base64_encode("$1").\'%%MFUNC%%\'', $this->content);
27 $this->content = preg_replace('#(<!--dynamic-cached-content-->.*<!--/dynamic-cached-content-->)#ise','\'%%MFUNC%%\'.base64_encode("$0").\'%%MFUNC%%\'', $this->content);
28 $restore_mfuncs=true;
29 }
30
31 $options = array('keepComments' => $this->keepcomments);
32 $this->content = Minify_HTML::minify($this->content,$options);
33
34
35 if (isset($restore_mfuncs)) {
36 $this->content = preg_replace('#%%MFUNC%%(.*)%%MFUNC%%#sie','stripslashes(base64_decode("$1"))',$this->content);
37 }
38
39 return true;
40 }
41
42 //Didn't minify :(
43 return false;
44 }
45
46 //Does nothing
47 public function cache()
48 {
49 //No cache for HTML
50 return true;
51 }
52
53 //Returns the content
54 public function getcontent()
55 {
56 return $this->content;
57 }
58 }
59