@@ -139,10 +139,18 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // hide everything between noptimize-comment tags |
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param string $noptimize_in |
|
| 145 | + */ |
|
| 142 | 146 | protected function hide_noptimize($noptimize_in) { |
| 143 | 147 | if ( preg_match( '/<!--\s?noptimize\s?-->/', $noptimize_in ) ) { |
| 144 | 148 | $noptimize_out = preg_replace_callback( |
| 145 | 149 | '#<!--\s?noptimize\s?-->.*?<!--\s?/\s?noptimize\s?-->#is', |
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param string $matches |
|
| 153 | + */ |
|
| 146 | 154 | function ($matches) {return "%%NOPTIMIZE" . AUTOPTIMIZE_HASH . "%%" . base64_encode($matches[0]) . "%%NOPTIMIZE%%";}, |
| 147 | 155 | $noptimize_in |
| 148 | 156 | ); |
@@ -268,6 +276,9 @@ discard block |
||
| 268 | 276 | } |
| 269 | 277 | } |
| 270 | 278 | |
| 279 | + /** |
|
| 280 | + * @param string $tag |
|
| 281 | + */ |
|
| 271 | 282 | protected function isremovable($tag, $removables) { |
| 272 | 283 | foreach ($removables as $match) { |
| 273 | 284 | if (strpos($tag,$match)!==false) { |
@@ -278,10 +289,18 @@ discard block |
||
| 278 | 289 | } |
| 279 | 290 | |
| 280 | 291 | // inject already minified code in optimized JS/CSS |
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @return string |
|
| 295 | + */ |
|
| 281 | 296 | protected function inject_minified($in) { |
| 282 | 297 | if ( strpos( $in, '%%INJECTLATER%%' ) !== false ) { |
| 283 | 298 | $out = preg_replace_callback( |
| 284 | 299 | '#\/\*\!%%INJECTLATER'.AUTOPTIMIZE_HASH.'%%(.*?)%%INJECTLATER%%\*\/#is', |
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * @return string |
|
| 303 | + */ |
|
| 285 | 304 | function ($matches) {$filepath = base64_decode(strtok($matches[1], "|")); |
| 286 | 305 | $filecontent = file_get_contents($filepath); |
| 287 | 306 | |
@@ -320,6 +339,9 @@ discard block |
||
| 320 | 339 | return $out; |
| 321 | 340 | } |
| 322 | 341 | |
| 342 | + /** |
|
| 343 | + * @param string $pathIn |
|
| 344 | + */ |
|
| 323 | 345 | protected function minify_single($pathIn) { |
| 324 | 346 | // determine JS or CSS and set var (also mimetype), return false if neither |
| 325 | 347 | if ( $this->str_ends_in($pathIn,".js") === true ) { |
@@ -385,6 +407,9 @@ discard block |
||
| 385 | 407 | return $_CachedMinifiedUrl; |
| 386 | 408 | } |
| 387 | 409 | |
| 410 | + /** |
|
| 411 | + * @param string $needle |
|
| 412 | + */ |
|
| 388 | 413 | protected function str_ends_in($haystack,$needle) { |
| 389 | 414 | $needleLength = strlen($needle); |
| 390 | 415 | $haystackLength = strlen($haystack); |