| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
|
| 5 |
class autoptimizeHTML extends autoptimizeBase { |
| 6 |
private $keepcomments = false; |
| 7 |
|
| 8 |
//Does nothing |
| 9 |
public function read($options) |
| 10 |
{ |
| 11 |
//Remove the HTML comments? |
| 12 |
$this->keepcomments = (bool) $options['keepcomments']; |
| 13 |
|
| 14 |
//Nothing to read for HTML |
| 15 |
return true; |
| 16 |
} |
| 17 |
|
| 18 |
//Joins and optimizes CSS |
| 19 |
public function minify() |
| 20 |
{ |
| 21 |
if(class_exists('Minify_HTML')) |
| 22 |
{ |
| 23 |
// noptimize me |
| 24 |
$this->content = $this->hide_noptimize($this->content); |
| 25 |
|
| 26 |
// Minify html |
| 27 |
$options = array('keepComments' => $this->keepcomments); |
| 28 |
|
| 29 |
if (is_callable(array(new Minify_HTML,"minify"))) { |
| 30 |
$tmp_content = Minify_HTML::minify($this->content,$options); |
| 31 |
if (!empty($tmp_content)) { |
| 32 |
$this->content = $tmp_content; |
| 33 |
unset($tmp_content); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
// restore noptimize |
| 38 |
$this->content = $this->restore_noptimize($this->content); |
| 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 |
|