@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $this->_html = str_replace("\r\n", "\n", trim($html)); |
| 72 | 72 | if (isset($options['xhtml'])) { |
| 73 | - $this->_isXhtml = (bool)$options['xhtml']; |
|
| 73 | + $this->_isXhtml = (bool) $options['xhtml']; |
|
| 74 | 74 | } |
| 75 | 75 | if (isset($options['cssMinifier'])) { |
| 76 | 76 | $this->_cssMinifier = $options['cssMinifier']; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML')); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']); |
|
| 98 | + $this->_replacementHash = 'MINIFYHTML'.md5($_SERVER['REQUEST_TIME']); |
|
| 99 | 99 | $this->_placeholders = array(); |
| 100 | 100 | |
| 101 | 101 | // replace SCRIPTs (and minify) with placeholders |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | ,$this->_html); |
| 112 | 112 | |
| 113 | 113 | // remove HTML comments (not containing IE conditional comments). |
| 114 | - if ($this->_keepComments == false) { |
|
| 114 | + if ($this->_keepComments == false) { |
|
| 115 | 115 | $this->_html = preg_replace_callback( |
| 116 | 116 | '/<!--([\\s\\S]*?)-->/' |
| 117 | 117 | ,array($this, '_commentCB') |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | protected function _reservePlace($content) |
| 175 | 175 | { |
| 176 | - $placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%'; |
|
| 176 | + $placeholder = '%'.$this->_replacementHash.count($this->_placeholders).'%'; |
|
| 177 | 177 | $this->_placeholders[$placeholder] = $content; |
| 178 | 178 | return $placeholder; |
| 179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | protected function _outsideTagCB($m) |
| 189 | 189 | { |
| 190 | - return '>' . preg_replace('/^\\s+|\\s+$/', ' ', $m[1]) . '<'; |
|
| 190 | + return '>'.preg_replace('/^\\s+|\\s+$/', ' ', $m[1]).'<'; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | protected function _removePreCB($m) |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | protected function _removeCdata($str) |
| 258 | 258 | { |
| 259 | 259 | return (false !== strpos($str, '<![CDATA[')) |
| 260 | - ? str_replace(array('/* <![CDATA[ */','/* ]]> */','/*<![CDATA[*/','/*]]>*/','<![CDATA[', ']]>'), '', $str) |
|
| 260 | + ? str_replace(array('/* <![CDATA[ */', '/* ]]> */', '/*<![CDATA[*/', '/*]]>*/', '<![CDATA[', ']]>'), '', $str) |
|
| 261 | 261 | : $str; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -66,11 +66,11 @@ |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - // revslider data attribs somehow suffer from HTML optimization, this fixes that |
|
| 69 | + // revslider data attribs somehow suffer from HTML optimization, this fixes that |
|
| 70 | 70 | if ( class_exists('RevSlider') || apply_filters('autoptimize_filter_html_dataattrib_cleanup', false) ) { |
| 71 | - $this->content = preg_replace('#\n(data-.*$)\n#Um',' $1 ', $this->content); |
|
| 72 | - $this->content = preg_replace('#(=\"[^"]*\")(\w)#','$1 $2', $this->content); |
|
| 73 | - } |
|
| 71 | + $this->content = preg_replace('#\n(data-.*$)\n#Um',' $1 ', $this->content); |
|
| 72 | + $this->content = preg_replace('#(=\"[^"]*\")(\w)#','$1 $2', $this->content); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | return true; |
| 76 | 76 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | class autoptimizeHTML extends autoptimizeBase { |
| 5 | 5 | private $keepcomments = false; |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | $this->keepcomments = (bool) $options['keepcomments']; |
| 11 | 11 | |
| 12 | 12 | // filter to force xhtml |
| 13 | - $this->forcexhtml = (bool) apply_filters( 'autoptimize_filter_html_forcexhtml', false ); |
|
| 13 | + $this->forcexhtml = (bool) apply_filters('autoptimize_filter_html_forcexhtml', false); |
|
| 14 | 14 | |
| 15 | 15 | // filter to add strings to be excluded from HTML minification |
| 16 | - $excludeHTML = apply_filters( 'autoptimize_filter_html_exclude','' ); |
|
| 17 | - if ($excludeHTML!=="") { |
|
| 18 | - $exclHTMLArr = array_filter(array_map('trim',explode(",",$excludeHTML))); |
|
| 19 | - $this->exclude = array_merge($exclHTMLArr,$this->exclude); |
|
| 16 | + $excludeHTML = apply_filters('autoptimize_filter_html_exclude', ''); |
|
| 17 | + if ($excludeHTML !== "") { |
|
| 18 | + $exclHTMLArr = array_filter(array_map('trim', explode(",", $excludeHTML))); |
|
| 19 | + $this->exclude = array_merge($exclHTMLArr, $this->exclude); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Nothing else for HTML |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | //Joins and optimizes CSS |
| 27 | 27 | public function minify() { |
| 28 | - $noptimizeHTML = apply_filters( 'autoptimize_filter_html_noptimize', false, $this->content ); |
|
| 28 | + $noptimizeHTML = apply_filters('autoptimize_filter_html_noptimize', false, $this->content); |
|
| 29 | 29 | if ($noptimizeHTML) |
| 30 | 30 | return false; |
| 31 | 31 | |
| 32 | - if(class_exists('Minify_HTML')) { |
|
| 32 | + if (class_exists('Minify_HTML')) { |
|
| 33 | 33 | // wrap the to-be-excluded strings in noptimize tags |
| 34 | 34 | foreach ($this->exclude as $exclString) { |
| 35 | - if (strpos($this->content,$exclString)!==false) { |
|
| 36 | - $replString="<!--noptimize-->".$exclString."<!--/noptimize-->"; |
|
| 37 | - $this->content=str_replace($exclString,$replString,$this->content); |
|
| 35 | + if (strpos($this->content, $exclString) !== false) { |
|
| 36 | + $replString = "<!--noptimize-->".$exclString."<!--/noptimize-->"; |
|
| 37 | + $this->content = str_replace($exclString, $replString, $this->content); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | $options['xhtml'] = true; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (@is_callable(array("Minify_HTML","minify"))) { |
|
| 51 | - $tmp_content = Minify_HTML::minify($this->content,$options); |
|
| 50 | + if (@is_callable(array("Minify_HTML", "minify"))) { |
|
| 51 | + $tmp_content = Minify_HTML::minify($this->content, $options); |
|
| 52 | 52 | if (!empty($tmp_content)) { |
| 53 | 53 | $this->content = $tmp_content; |
| 54 | 54 | unset($tmp_content); |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // remove the noptimize-wrapper from around the excluded strings |
| 62 | 62 | foreach ($this->exclude as $exclString) { |
| 63 | - $replString="<!--noptimize-->".$exclString."<!--/noptimize-->"; |
|
| 64 | - if (strpos($this->content,$replString)!==false) { |
|
| 65 | - $this->content=str_replace($replString,$exclString,$this->content); |
|
| 63 | + $replString = "<!--noptimize-->".$exclString."<!--/noptimize-->"; |
|
| 64 | + if (strpos($this->content, $replString) !== false) { |
|
| 65 | + $this->content = str_replace($replString, $exclString, $this->content); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // revslider data attribs somehow suffer from HTML optimization, this fixes that |
| 70 | - if ( class_exists('RevSlider') || apply_filters('autoptimize_filter_html_dataattrib_cleanup', false) ) { |
|
| 71 | - $this->content = preg_replace('#\n(data-.*$)\n#Um',' $1 ', $this->content); |
|
| 72 | - $this->content = preg_replace('#(=\"[^"]*\")(\w)#','$1 $2', $this->content); |
|
| 70 | + if (class_exists('RevSlider') || apply_filters('autoptimize_filter_html_dataattrib_cleanup', false)) { |
|
| 71 | + $this->content = preg_replace('#\n(data-.*$)\n#Um', ' $1 ', $this->content); |
|
| 72 | + $this->content = preg_replace('#(=\"[^"]*\")(\w)#', '$1 $2', $this->content); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return true; |