@@ -699,6 +699,11 @@ discard block |
||
| 699 | 699 | * --------------------------------------------------------------------------------------------- |
| 700 | 700 | */ |
| 701 | 701 | |
| 702 | + /** |
|
| 703 | + * @param double $v1 |
|
| 704 | + * @param double $v2 |
|
| 705 | + * @param integer $vh |
|
| 706 | + */ |
|
| 702 | 707 | private function hue_to_rgb($v1, $v2, $vh) |
| 703 | 708 | { |
| 704 | 709 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
@@ -713,6 +718,10 @@ discard block |
||
| 713 | 718 | return intval(floor(floatval($n) + 0.5), 10); |
| 714 | 719 | } |
| 715 | 720 | |
| 721 | + /** |
|
| 722 | + * @param integer $min |
|
| 723 | + * @param integer $max |
|
| 724 | + */ |
|
| 716 | 725 | private function clamp_number($n, $min, $max) |
| 717 | 726 | { |
| 718 | 727 | return min(max($n, $min), $max); |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | // Normalize all whitespace strings to single spaces. Easier to work with that way. |
| 285 | 285 | $css = preg_replace('/\s+/', ' ', $css); |
| 286 | 286 | |
| 287 | - // Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters |
|
| 288 | - $css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css); |
|
| 287 | + // Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters |
|
| 288 | + $css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css); |
|
| 289 | 289 | |
| 290 | 290 | // Shorten & preserve calculations calc(...) since spaces are important |
| 291 | 291 | $css = preg_replace_callback('/calc(\(((?:[^\(\)]+|(?1))*)\))/i', array($this, 'replace_calc'), $css); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | // Add "/" back to fix Opera -o-device-pixel-ratio query |
| 389 | 389 | $css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css); |
| 390 | 390 | |
| 391 | - // Replace multiple semi-colons in a row by a single one |
|
| 391 | + // Replace multiple semi-colons in a row by a single one |
|
| 392 | 392 | // See SF bug #1980989 |
| 393 | 393 | $css = preg_replace('/;;+/', ';', $css); |
| 394 | 394 | |
@@ -603,10 +603,10 @@ discard block |
||
| 603 | 603 | return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - private function preserve_old_IE_specific_matrix_definition($matches) |
|
| 607 | - { |
|
| 608 | - $this->preserved_tokens[] = $matches[1]; |
|
| 609 | - return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
|
| 606 | + private function preserve_old_IE_specific_matrix_definition($matches) |
|
| 607 | + { |
|
| 608 | + $this->preserved_tokens[] = $matches[1]; |
|
| 609 | + return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | private function rgb_to_hex($matches) |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct($raise_php_limits = TRUE) |
| 46 | 46 | { |
| 47 | - $this->memory_limit = 128 * 1048576; // 128MB in bytes |
|
| 48 | - $this->pcre_backtrack_limit = 1000 * 1000; |
|
| 49 | - $this->pcre_recursion_limit = 500 * 1000; |
|
| 47 | + $this->memory_limit = 128*1048576; // 128MB in bytes |
|
| 48 | + $this->pcre_backtrack_limit = 1000*1000; |
|
| 49 | + $this->pcre_recursion_limit = 500*1000; |
|
| 50 | 50 | |
| 51 | 51 | $this->raise_php_limits = (bool) $raise_php_limits; |
| 52 | 52 | } |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | $comment_found = $this->str_slice($css, $start_index + 2, $end_index); |
| 85 | 85 | $this->comments[] = $comment_found; |
| 86 | - $comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___'; |
|
| 87 | - $css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index); |
|
| 86 | + $comment_preserve_string = self::COMMENT.(count($this->comments) - 1).'___'; |
|
| 87 | + $css = $this->str_slice($css, 0, $start_index + 2).$comment_preserve_string.$this->str_slice($css, $end_index); |
|
| 88 | 88 | // Set correct start_index: Fixes issue #2528130 |
| 89 | 89 | $start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found); |
| 90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $charset = ''; |
| 102 | 102 | $charset_regexp = '/(@charset)( [^;]+;)/i'; |
| 103 | 103 | $css_chunks = array(); |
| 104 | - $increment = $this->chunk_length / 100; |
|
| 104 | + $increment = $this->chunk_length/100; |
|
| 105 | 105 | $start_index = 0; |
| 106 | 106 | $i = $this->chunk_length; // save initial iterations |
| 107 | 107 | $l = strlen($css); |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | $css_chunks[$i] = $this->minify($css_chunks[$i], $linebreak_pos); |
| 138 | 138 | // Keep the first @charset at-rule found |
| 139 | 139 | if (empty($charset) && preg_match($charset_regexp, $css_chunks[$i], $matches)) { |
| 140 | - $charset = strtolower($matches[1]) . $matches[2]; |
|
| 140 | + $charset = strtolower($matches[1]).$matches[2]; |
|
| 141 | 141 | } |
| 142 | 142 | // Delete all @charset at-rules |
| 143 | 143 | $css_chunks[$i] = preg_replace($charset_regexp, '', $css_chunks[$i]); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Update the first chunk and push the charset to the top of the file. |
| 147 | - $css_chunks[0] = $charset . $css_chunks[0]; |
|
| 147 | + $css_chunks[0] = $charset.$css_chunks[0]; |
|
| 148 | 148 | |
| 149 | 149 | return implode('', $css_chunks); |
| 150 | 150 | } |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | for ($i = 0, $max = count($this->comments); $i < $max; $i++) { |
| 240 | 240 | |
| 241 | 241 | $token = $this->comments[$i]; |
| 242 | - $placeholder = '/' . self::COMMENT . $i . '___/'; |
|
| 242 | + $placeholder = '/'.self::COMMENT.$i.'___/'; |
|
| 243 | 243 | |
| 244 | 244 | // ! in the first position of the comment means preserve |
| 245 | 245 | // so push to the preserved tokens keeping the ! |
| 246 | 246 | if (substr($token, 0, 1) === '!') { |
| 247 | 247 | $this->preserved_tokens[] = $token; |
| 248 | - $token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___'; |
|
| 248 | + $token_tring = self::TOKEN.(count($this->preserved_tokens) - 1).'___'; |
|
| 249 | 249 | $css = preg_replace($placeholder, $token_tring, $css, 1); |
| 250 | 250 | // Preserve new lines for /*! important comments |
| 251 | - $css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css); |
|
| 252 | - $css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/', '$1'.self::NL, $css); |
|
| 251 | + $css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'.$token_tring.')/S', self::NL.'$1', $css); |
|
| 252 | + $css = preg_replace('/('.$token_tring.'\*\/)\s*[\n\r\f]+\s*/', '$1'.self::NL, $css); |
|
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | // shorten that to /*\*/ and the next one to /**/ |
| 258 | 258 | if (substr($token, (strlen($token) - 1), 1) === '\\') { |
| 259 | 259 | $this->preserved_tokens[] = '\\'; |
| 260 | - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
| 260 | + $css = preg_replace($placeholder, self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1); |
|
| 261 | 261 | $i = $i + 1; // attn: advancing the loop |
| 262 | 262 | $this->preserved_tokens[] = ''; |
| 263 | - $css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
| 263 | + $css = preg_replace('/'.self::COMMENT.$i.'___/', self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1); |
|
| 264 | 264 | continue; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | if ($start_index > 2) { |
| 272 | 272 | if (substr($css, $start_index - 3, 1) === '>') { |
| 273 | 273 | $this->preserved_tokens[] = ''; |
| 274 | - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
| 274 | + $css = preg_replace($placeholder, self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1); |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // in all other cases kill the comment |
| 280 | - $css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1); |
|
| 280 | + $css = preg_replace('/\/\*'.$this->str_slice($placeholder, 1, -1).'\*\//', '', $css, 1); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $css = preg_replace('/\!important/i', ' !important', $css); |
| 321 | 321 | |
| 322 | 322 | // bring back the colon |
| 323 | - $css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css); |
|
| 323 | + $css = preg_replace('/'.self::CLASSCOLON.'/', ':', $css); |
|
| 324 | 324 | |
| 325 | 325 | // retain space for special IE6 cases |
| 326 | 326 | $css = preg_replace_callback('/\:first\-(line|letter)(\{|,)/i', array($this, 'lowercase_pseudo_first'), $css); |
@@ -380,20 +380,20 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | // Find a fraction that is used for Opera's -o-device-pixel-ratio query |
| 382 | 382 | // Add token to add the "\" back in later |
| 383 | - $css = preg_replace('/\(([a-z\-]+):([0-9]+)\/([0-9]+)\)/i', '($1:$2'. self::QUERY_FRACTION .'$3)', $css); |
|
| 383 | + $css = preg_replace('/\(([a-z\-]+):([0-9]+)\/([0-9]+)\)/i', '($1:$2'.self::QUERY_FRACTION.'$3)', $css); |
|
| 384 | 384 | |
| 385 | 385 | // Remove empty rules. |
| 386 | 386 | $css = preg_replace('/[^\};\{\/]+\{\}/S', '', $css); |
| 387 | 387 | |
| 388 | 388 | // Add "/" back to fix Opera -o-device-pixel-ratio query |
| 389 | - $css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css); |
|
| 389 | + $css = preg_replace('/'.self::QUERY_FRACTION.'/', '/', $css); |
|
| 390 | 390 | |
| 391 | 391 | // Replace multiple semi-colons in a row by a single one |
| 392 | 392 | // See SF bug #1980989 |
| 393 | 393 | $css = preg_replace('/;;+/', ';', $css); |
| 394 | 394 | |
| 395 | 395 | // Restore new lines for /*! important comments |
| 396 | - $css = preg_replace('/'. self::NL .'/', "\n", $css); |
|
| 396 | + $css = preg_replace('/'.self::NL.'/', "\n", $css); |
|
| 397 | 397 | |
| 398 | 398 | // Lowercase all uppercase properties |
| 399 | 399 | $css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | while ($i < strlen($css)) { |
| 408 | 408 | $i++; |
| 409 | 409 | if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) { |
| 410 | - $css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i); |
|
| 410 | + $css = $this->str_slice($css, 0, $i)."\n".$this->str_slice($css, $i); |
|
| 411 | 411 | $start_index = $i; |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | // restore preserved comments and strings in reverse order |
| 417 | 417 | for ($i = count($this->preserved_tokens) - 1; $i >= 0; $i--) { |
| 418 | - $css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1); |
|
| 418 | + $css = preg_replace('/'.self::TOKEN.$i.'___/', $this->preserved_tokens[$i], $css, 1); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Trim the final string (for any leading or trailing white spaces) |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $terminator = ')'; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - while ($found_terminator === FALSE && $end_index+1 <= $max_index) { |
|
| 458 | + while ($found_terminator === FALSE && $end_index + 1 <= $max_index) { |
|
| 459 | 459 | $end_index = $this->index_of($css, $terminator, $end_index + 1); |
| 460 | 460 | |
| 461 | 461 | // endIndex == 0 doesn't really apply here |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $token = preg_replace_callback('/.+base64,.+/s', array($this, 'remove_data_urls_spaces'), $token); |
| 477 | 477 | $this->preserved_tokens[] = trim($token); |
| 478 | 478 | |
| 479 | - $preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)'; |
|
| 479 | + $preserver = 'url('.self::TOKEN.(count($this->preserved_tokens) - 1).'___)'; |
|
| 480 | 480 | $sb[] = $preserver; |
| 481 | 481 | |
| 482 | 482 | $append_index = $end_index + 1; |
@@ -538,16 +538,16 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | if ($is_filter) { |
| 540 | 540 | // Restore, maintain case, otherwise filter will break |
| 541 | - $sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]; |
|
| 541 | + $sb[] = $m[1].'#'.$m[2].$m[3].$m[4].$m[5].$m[6].$m[7]; |
|
| 542 | 542 | } else { |
| 543 | 543 | if (strtolower($m[2]) == strtolower($m[3]) && |
| 544 | 544 | strtolower($m[4]) == strtolower($m[5]) && |
| 545 | 545 | strtolower($m[6]) == strtolower($m[7])) { |
| 546 | 546 | // Compress. |
| 547 | - $hex = '#' . strtolower($m[3] . $m[5] . $m[7]); |
|
| 547 | + $hex = '#'.strtolower($m[3].$m[5].$m[7]); |
|
| 548 | 548 | } else { |
| 549 | 549 | // Non compressible color, restore but lower case. |
| 550 | - $hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]); |
|
| 550 | + $hex = '#'.strtolower($m[2].$m[3].$m[4].$m[5].$m[6].$m[7]); |
|
| 551 | 551 | } |
| 552 | 552 | // replace Hex colors to short safe color names |
| 553 | 553 | $sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | // one, maybe more? put'em back then |
| 582 | 582 | if (($pos = $this->index_of($match, self::COMMENT)) >= 0) { |
| 583 | 583 | for ($i = 0, $max = count($this->comments); $i < $max; $i++) { |
| 584 | - $match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1); |
|
| 584 | + $match = preg_replace('/'.self::COMMENT.$i.'___/', $this->comments[$i], $match, 1); |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | $match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match); |
| 590 | 590 | |
| 591 | 591 | $this->preserved_tokens[] = $match; |
| 592 | - return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote; |
|
| 592 | + return $quote.self::TOKEN.(count($this->preserved_tokens) - 1).'___'.$quote; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | private function replace_colon($matches) |
@@ -599,23 +599,23 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | private function replace_calc($matches) |
| 601 | 601 | { |
| 602 | - $this->preserved_tokens[] = preg_replace('/\)([\+\-]{1})/',') $1',preg_replace('/([\+\-]{1})\(/','$1 (',trim(preg_replace('/\s*([\*\/\(\),])\s*/', '$1', $matches[2])))); |
|
| 603 | - return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
|
| 602 | + $this->preserved_tokens[] = preg_replace('/\)([\+\-]{1})/', ') $1', preg_replace('/([\+\-]{1})\(/', '$1 (', trim(preg_replace('/\s*([\*\/\(\),])\s*/', '$1', $matches[2])))); |
|
| 603 | + return 'calc('.self::TOKEN.(count($this->preserved_tokens) - 1).'___'.')'; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | private function preserve_old_IE_specific_matrix_definition($matches) |
| 607 | 607 | { |
| 608 | 608 | $this->preserved_tokens[] = $matches[1]; |
| 609 | - return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
|
| 609 | + return 'filter:progid:DXImageTransform.Microsoft.Matrix('.self::TOKEN.(count($this->preserved_tokens) - 1).'___'.')'; |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | private function rgb_to_hex($matches) |
| 613 | 613 | { |
| 614 | 614 | // Support for percentage values rgb(100%, 0%, 45%); |
| 615 | - if ($this->index_of($matches[1], '%') >= 0){ |
|
| 615 | + if ($this->index_of($matches[1], '%') >= 0) { |
|
| 616 | 616 | $rgbcolors = explode(',', str_replace('%', '', $matches[1])); |
| 617 | 617 | for ($i = 0; $i < count($rgbcolors); $i++) { |
| 618 | - $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55); |
|
| 618 | + $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i])*2.55); |
|
| 619 | 619 | } |
| 620 | 620 | } else { |
| 621 | 621 | $rgbcolors = explode(',', $matches[1]); |
@@ -628,11 +628,11 @@ discard block |
||
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // Fix for issue #2528093 |
| 631 | - if (!preg_match('/[\s\,\);\}]/', $matches[2])){ |
|
| 632 | - $matches[2] = ' ' . $matches[2]; |
|
| 631 | + if (!preg_match('/[\s\,\);\}]/', $matches[2])) { |
|
| 632 | + $matches[2] = ' '.$matches[2]; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - return '#' . implode('', $rgbcolors) . $matches[2]; |
|
| 635 | + return '#'.implode('', $rgbcolors).$matches[2]; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | private function hsl_to_hex($matches) |
@@ -643,18 +643,18 @@ discard block |
||
| 643 | 643 | $l = floatval($values[2]); |
| 644 | 644 | |
| 645 | 645 | // Wrap and clamp, then fraction! |
| 646 | - $h = ((($h % 360) + 360) % 360) / 360; |
|
| 647 | - $s = $this->clamp_number($s, 0, 100) / 100; |
|
| 648 | - $l = $this->clamp_number($l, 0, 100) / 100; |
|
| 646 | + $h = ((($h%360) + 360)%360)/360; |
|
| 647 | + $s = $this->clamp_number($s, 0, 100)/100; |
|
| 648 | + $l = $this->clamp_number($l, 0, 100)/100; |
|
| 649 | 649 | |
| 650 | 650 | if ($s == 0) { |
| 651 | - $r = $g = $b = $this->round_number(255 * $l); |
|
| 651 | + $r = $g = $b = $this->round_number(255*$l); |
|
| 652 | 652 | } else { |
| 653 | - $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l); |
|
| 654 | - $v1 = (2 * $l) - $v2; |
|
| 655 | - $r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3))); |
|
| 656 | - $g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h)); |
|
| 657 | - $b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3))); |
|
| 653 | + $v2 = $l < 0.5 ? $l*(1 + $s) : ($l + $s) - ($s*$l); |
|
| 654 | + $v1 = (2*$l) - $v2; |
|
| 655 | + $r = $this->round_number(255*$this->hue_to_rgb($v1, $v2, $h + (1/3))); |
|
| 656 | + $g = $this->round_number(255*$this->hue_to_rgb($v1, $v2, $h)); |
|
| 657 | + $b = $this->round_number(255*$this->hue_to_rgb($v1, $v2, $h - (1/3))); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2])); |
@@ -662,32 +662,32 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | private function lowercase_at_rules_operators($matches) |
| 664 | 664 | { |
| 665 | - return $matches[1] . strtolower($matches[2]) . ' ('; |
|
| 665 | + return $matches[1].strtolower($matches[2]).' ('; |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | private function lowercase_pseudo_first($matches) |
| 669 | 669 | { |
| 670 | - return ':first-'. strtolower($matches[1]) .' '. $matches[2]; |
|
| 670 | + return ':first-'.strtolower($matches[1]).' '.$matches[2]; |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | private function lowercase_directives($matches) |
| 674 | 674 | { |
| 675 | - return '@'. strtolower($matches[1]); |
|
| 675 | + return '@'.strtolower($matches[1]); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | private function lowercase_pseudo_elements($matches) |
| 679 | 679 | { |
| 680 | - return ':'. strtolower($matches[1]); |
|
| 680 | + return ':'.strtolower($matches[1]); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | private function lowercase_common_functions($matches) |
| 684 | 684 | { |
| 685 | - return ':'. strtolower($matches[1]) .'('; |
|
| 685 | + return ':'.strtolower($matches[1]).'('; |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | private function lowercase_common_functions_values($matches) |
| 689 | 689 | { |
| 690 | - return $matches[1] . strtolower($matches[2]); |
|
| 690 | + return $matches[1].strtolower($matches[2]); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | private function lowercase_properties($matches) |
@@ -702,9 +702,9 @@ discard block |
||
| 702 | 702 | private function hue_to_rgb($v1, $v2, $vh) |
| 703 | 703 | { |
| 704 | 704 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
| 705 | - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
|
| 706 | - if ($vh * 2 < 1) return $v2; |
|
| 707 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
| 705 | + if ($vh*6 < 1) return $v1 + ($v2 - $v1)*6*$vh; |
|
| 706 | + if ($vh*2 < 1) return $v2; |
|
| 707 | + if ($vh*3 < 2) return $v1 + ($v2 - $v1)*((2/3) - $vh)*6; |
|
| 708 | 708 | return $v1; |
| 709 | 709 | } |
| 710 | 710 | |
@@ -780,9 +780,9 @@ discard block |
||
| 780 | 780 | $letter = substr($size, -1); |
| 781 | 781 | $size = intval($size); |
| 782 | 782 | switch ($letter) { |
| 783 | - case 'M': case 'm': return (int) $size * 1048576; |
|
| 784 | - case 'K': case 'k': return (int) $size * 1024; |
|
| 785 | - case 'G': case 'g': return (int) $size * 1073741824; |
|
| 783 | + case 'M': case 'm': return (int) $size*1048576; |
|
| 784 | + case 'K': case 'k': return (int) $size*1024; |
|
| 785 | + case 'G': case 'g': return (int) $size*1073741824; |
|
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | return (int) $size; |
@@ -701,9 +701,15 @@ |
||
| 701 | 701 | private function hue_to_rgb($v1, $v2, $vh) |
| 702 | 702 | { |
| 703 | 703 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
| 704 | - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
|
| 705 | - if ($vh * 2 < 1) return $v2; |
|
| 706 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
| 704 | + if ($vh * 6 < 1) { |
|
| 705 | + return $v1 + ($v2 - $v1) * 6 * $vh; |
|
| 706 | + } |
|
| 707 | + if ($vh * 2 < 1) { |
|
| 708 | + return $v2; |
|
| 709 | + } |
|
| 710 | + if ($vh * 3 < 2) { |
|
| 711 | + return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
| 712 | + } |
|
| 707 | 713 | return $v1; |
| 708 | 714 | } |
| 709 | 715 | |
@@ -12,15 +12,15 @@ discard block |
||
| 12 | 12 | http://www.gnu.org/licenses/gpl.txt |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 15 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 16 | 16 | |
| 17 | -define('AUTOPTIMIZE_PLUGIN_DIR',plugin_dir_path(__FILE__)); |
|
| 17 | +define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
| 18 | 18 | |
| 19 | 19 | // Load config class |
| 20 | 20 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeConfig.php'); |
| 21 | 21 | |
| 22 | 22 | // Load toolbar class |
| 23 | -include( AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeToolbar.php' ); |
|
| 23 | +include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeToolbar.php'); |
|
| 24 | 24 | |
| 25 | 25 | // Load partners tab if admin |
| 26 | 26 | if (is_admin()) { |
@@ -28,25 +28,25 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // Do we gzip when caching (needed early to load autoptimizeCache.php) |
| 31 | -define('AUTOPTIMIZE_CACHE_NOGZIP',(bool) get_option('autoptimize_cache_nogzip')); |
|
| 31 | +define('AUTOPTIMIZE_CACHE_NOGZIP', (bool) get_option('autoptimize_cache_nogzip')); |
|
| 32 | 32 | |
| 33 | 33 | // Load cache class |
| 34 | 34 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCache.php'); |
| 35 | 35 | |
| 36 | 36 | // wp-content dir name (automagically set, should not be needed), dirname of AO cache dir and AO-prefix can be overridden in wp-config.php |
| 37 | -if (!defined('AUTOPTIMIZE_WP_CONTENT_NAME')) { define('AUTOPTIMIZE_WP_CONTENT_NAME','/'.wp_basename( WP_CONTENT_DIR )); } |
|
| 38 | -if (!defined('AUTOPTIMIZE_CACHE_CHILD_DIR')) { define('AUTOPTIMIZE_CACHE_CHILD_DIR','/cache/autoptimize/'); } |
|
| 37 | +if (!defined('AUTOPTIMIZE_WP_CONTENT_NAME')) { define('AUTOPTIMIZE_WP_CONTENT_NAME', '/'.wp_basename(WP_CONTENT_DIR)); } |
|
| 38 | +if (!defined('AUTOPTIMIZE_CACHE_CHILD_DIR')) { define('AUTOPTIMIZE_CACHE_CHILD_DIR', '/cache/autoptimize/'); } |
|
| 39 | 39 | if (!defined('AUTOPTIMIZE_CACHEFILE_PREFIX')) { define('AUTOPTIMIZE_CACHEFILE_PREFIX', 'autoptimize_'); } |
| 40 | 40 | |
| 41 | 41 | // Plugin dir constants (plugin url's defined later to accomodate domain mapped sites) |
| 42 | -if (is_multisite() && apply_filters( 'autoptimize_separate_blog_caches' , true )) { |
|
| 42 | +if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) { |
|
| 43 | 43 | $blog_id = get_current_blog_id(); |
| 44 | - define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/' ); |
|
| 44 | + define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/'); |
|
| 45 | 45 | } else { |
| 46 | 46 | define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR); |
| 47 | 47 | } |
| 48 | -define('AUTOPTIMIZE_CACHE_DELAY',true); |
|
| 49 | -define('WP_ROOT_DIR',str_replace(AUTOPTIMIZE_WP_CONTENT_NAME,'',WP_CONTENT_DIR)); |
|
| 48 | +define('AUTOPTIMIZE_CACHE_DELAY', true); |
|
| 49 | +define('WP_ROOT_DIR', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', WP_CONTENT_DIR)); |
|
| 50 | 50 | |
| 51 | 51 | // Initialize the cache at least once |
| 52 | 52 | $conf = autoptimizeConfig::instance(); |
@@ -54,65 +54,65 @@ discard block |
||
| 54 | 54 | /* Check if we're updating, in which case we might need to do stuff and flush the cache |
| 55 | 55 | to avoid old versions of aggregated files lingering around */ |
| 56 | 56 | |
| 57 | -$autoptimize_version="2.1.0"; |
|
| 58 | -$autoptimize_db_version=get_option('autoptimize_version','none'); |
|
| 57 | +$autoptimize_version = "2.1.0"; |
|
| 58 | +$autoptimize_db_version = get_option('autoptimize_version', 'none'); |
|
| 59 | 59 | |
| 60 | 60 | if ($autoptimize_db_version !== $autoptimize_version) { |
| 61 | - if ($autoptimize_db_version==="none") { |
|
| 61 | + if ($autoptimize_db_version === "none") { |
|
| 62 | 62 | add_action('admin_notices', 'autoptimize_install_config_notice'); |
| 63 | 63 | } else { |
| 64 | 64 | // updating, include the update-code |
| 65 | 65 | include(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeUpdateCode.php'); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - update_option('autoptimize_version',$autoptimize_version); |
|
| 69 | - $autoptimize_db_version=$autoptimize_version; |
|
| 68 | + update_option('autoptimize_version', $autoptimize_version); |
|
| 69 | + $autoptimize_db_version = $autoptimize_version; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Load translations |
| 73 | 73 | function autoptimize_load_plugin_textdomain() { |
| 74 | - load_plugin_textdomain('autoptimize',false,plugin_basename(dirname( __FILE__ )).'/localization'); |
|
| 74 | + load_plugin_textdomain('autoptimize', false, plugin_basename(dirname(__FILE__)).'/localization'); |
|
| 75 | 75 | } |
| 76 | -add_action( 'init', 'autoptimize_load_plugin_textdomain' ); |
|
| 76 | +add_action('init', 'autoptimize_load_plugin_textdomain'); |
|
| 77 | 77 | |
| 78 | -function autoptimize_uninstall(){ |
|
| 78 | +function autoptimize_uninstall() { |
|
| 79 | 79 | autoptimizeCache::clearall(); |
| 80 | 80 | |
| 81 | - $delete_options=array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_defer_inline", "autoptimize_css_inline", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url", "autoptimize_cachesize_notice","autoptimize_css_include_inline","autoptimize_js_include_inline","autoptimize_css_nogooglefont","autoptimize_optimize_logged"); |
|
| 81 | + $delete_options = array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_defer_inline", "autoptimize_css_inline", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url", "autoptimize_cachesize_notice", "autoptimize_css_include_inline", "autoptimize_js_include_inline", "autoptimize_css_nogooglefont", "autoptimize_optimize_logged"); |
|
| 82 | 82 | |
| 83 | - if ( !is_multisite() ) { |
|
| 84 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
| 83 | + if (!is_multisite()) { |
|
| 84 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
| 85 | 85 | } else { |
| 86 | 86 | global $wpdb; |
| 87 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 87 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
| 88 | 88 | $original_blog_id = get_current_blog_id(); |
| 89 | - foreach ( $blog_ids as $blog_id ) { |
|
| 90 | - switch_to_blog( $blog_id ); |
|
| 91 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
| 89 | + foreach ($blog_ids as $blog_id) { |
|
| 90 | + switch_to_blog($blog_id); |
|
| 91 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
| 92 | 92 | } |
| 93 | - switch_to_blog( $original_blog_id ); |
|
| 93 | + switch_to_blog($original_blog_id); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ( wp_get_schedule( 'ao_cachechecker' ) ) { |
|
| 97 | - wp_clear_scheduled_hook( 'ao_cachechecker' ); |
|
| 96 | + if (wp_get_schedule('ao_cachechecker')) { |
|
| 97 | + wp_clear_scheduled_hook('ao_cachechecker'); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | function autoptimize_install_config_notice() { |
| 102 | 102 | echo '<div class="updated"><p>'; |
| 103 | - _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' ); |
|
| 103 | + _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize'); |
|
| 104 | 104 | echo '</p></div>'; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | function autoptimize_update_config_notice() { |
| 108 | 108 | echo '<div class="updated"><p>'; |
| 109 | - _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize' ); |
|
| 109 | + _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize'); |
|
| 110 | 110 | echo '</p></div>'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | function autoptimize_cache_unavailable_notice() { |
| 114 | 114 | echo '<div class="error"><p>'; |
| 115 | - printf( __( 'Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize' ), AUTOPTIMIZE_CACHE_DIR ); |
|
| 115 | + printf(__('Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize'), AUTOPTIMIZE_CACHE_DIR); |
|
| 116 | 116 | echo '</p></div>'; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -121,26 +121,26 @@ discard block |
||
| 121 | 121 | $ao_noptimize = false; |
| 122 | 122 | |
| 123 | 123 | // noptimize in qs to get non-optimized page for debugging |
| 124 | - if (array_key_exists("ao_noptimize",$_GET)) { |
|
| 125 | - if ( ($_GET["ao_noptimize"]==="1") && (apply_filters('autoptimize_filter_honor_qs_noptimize',true)) ) { |
|
| 124 | + if (array_key_exists("ao_noptimize", $_GET)) { |
|
| 125 | + if (($_GET["ao_noptimize"] === "1") && (apply_filters('autoptimize_filter_honor_qs_noptimize', true))) { |
|
| 126 | 126 | $ao_noptimize = true; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // check for DONOTMINIFY constant as used by e.g. WooCommerce POS |
| 131 | - if (defined('DONOTMINIFY') && (constant('DONOTMINIFY')===true || constant('DONOTMINIFY')==="true")) { |
|
| 131 | + if (defined('DONOTMINIFY') && (constant('DONOTMINIFY') === true || constant('DONOTMINIFY') === "true")) { |
|
| 132 | 132 | $ao_noptimize = true; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // if setting says not to optimize logged in user and user is logged in |
| 136 | - if (get_option('autoptimize_optimize_logged','on') !== 'on' && is_user_logged_in()) { |
|
| 136 | + if (get_option('autoptimize_optimize_logged', 'on') !== 'on' && is_user_logged_in()) { |
|
| 137 | 137 | $ao_noptimize = true; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // filter you can use to block autoptimization on your own terms |
| 141 | - $ao_noptimize = (bool) apply_filters( 'autoptimize_filter_noptimize', $ao_noptimize ); |
|
| 141 | + $ao_noptimize = (bool) apply_filters('autoptimize_filter_noptimize', $ao_noptimize); |
|
| 142 | 142 | |
| 143 | - if (!is_feed() && !$ao_noptimize && !is_admin() && ( !function_exists('is_customize_preview') || !is_customize_preview() ) ) { |
|
| 143 | + if (!is_feed() && !$ao_noptimize && !is_admin() && (!function_exists('is_customize_preview') || !is_customize_preview())) { |
|
| 144 | 144 | // Config element |
| 145 | 145 | $conf = autoptimizeConfig::instance(); |
| 146 | 146 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeBase.php'); |
| 149 | 149 | |
| 150 | 150 | // Load extra classes and set some vars |
| 151 | - if($conf->get('autoptimize_html')) { |
|
| 151 | + if ($conf->get('autoptimize_html')) { |
|
| 152 | 152 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeHTML.php'); |
| 153 | 153 | // BUG: new minify-html does not support keeping HTML comments, skipping for now |
| 154 | 154 | // if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($conf->get('autoptimize_js')) { |
|
| 161 | + if ($conf->get('autoptimize_js')) { |
|
| 162 | 162 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeScripts.php'); |
| 163 | 163 | if (!class_exists('JSMin')) { |
| 164 | 164 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -167,15 +167,15 @@ discard block |
||
| 167 | 167 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/minify-2.3.1-jsmin.php'); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | - if ( ! defined( 'CONCATENATE_SCRIPTS' )) { |
|
| 171 | - define('CONCATENATE_SCRIPTS',false); |
|
| 170 | + if (!defined('CONCATENATE_SCRIPTS')) { |
|
| 171 | + define('CONCATENATE_SCRIPTS', false); |
|
| 172 | 172 | } |
| 173 | - if ( ! defined( 'COMPRESS_SCRIPTS' )) { |
|
| 174 | - define('COMPRESS_SCRIPTS',false); |
|
| 173 | + if (!defined('COMPRESS_SCRIPTS')) { |
|
| 174 | + define('COMPRESS_SCRIPTS', false); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if($conf->get('autoptimize_css')) { |
|
| 178 | + if ($conf->get('autoptimize_css')) { |
|
| 179 | 179 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeStyles.php'); |
| 180 | 180 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
| 181 | 181 | if (!class_exists('Minify_CSS_Compressor')) { |
@@ -186,13 +186,13 @@ discard block |
||
| 186 | 186 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/yui-php-cssmin-2.4.8-p9.php'); |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | - if ( ! defined( 'COMPRESS_CSS' )) { |
|
| 190 | - define('COMPRESS_CSS',false); |
|
| 189 | + if (!defined('COMPRESS_CSS')) { |
|
| 190 | + define('COMPRESS_CSS', false); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // filter to be used with care, kills all output buffers when true. use with extreme caution. you have been warned! |
| 195 | - if (apply_filters('autoptimize_filter_obkiller',false)) { |
|
| 195 | + if (apply_filters('autoptimize_filter_obkiller', false)) { |
|
| 196 | 196 | while (ob_get_level() > 0) { |
| 197 | 197 | ob_end_clean(); |
| 198 | 198 | } |
@@ -205,35 +205,35 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | // Action on end, this is where the magic happens |
| 207 | 207 | function autoptimize_end_buffering($content) { |
| 208 | - if ( ((stripos($content,"<html") === false) && (stripos($content,"<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/',$content) === 1 || stripos($content,"<xsl:stylesheet") !== false ) { return $content; } |
|
| 208 | + if (((stripos($content, "<html") === false) && (stripos($content, "<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/', $content) === 1 || stripos($content, "<xsl:stylesheet") !== false) { return $content; } |
|
| 209 | 209 | |
| 210 | 210 | // load URL constants as late as possible to allow domain mapper to kick in |
| 211 | 211 | if (function_exists("domain_mapping_siteurl")) { |
| 212 | - define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl(get_current_blog_id())); |
|
| 213 | - define('AUTOPTIMIZE_WP_CONTENT_URL',str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL),AUTOPTIMIZE_WP_SITE_URL,content_url())); |
|
| 212 | + define('AUTOPTIMIZE_WP_SITE_URL', domain_mapping_siteurl(get_current_blog_id())); |
|
| 213 | + define('AUTOPTIMIZE_WP_CONTENT_URL', str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL), AUTOPTIMIZE_WP_SITE_URL, content_url())); |
|
| 214 | 214 | } else { |
| 215 | - define('AUTOPTIMIZE_WP_SITE_URL',site_url()); |
|
| 216 | - define('AUTOPTIMIZE_WP_CONTENT_URL',content_url()); |
|
| 215 | + define('AUTOPTIMIZE_WP_SITE_URL', site_url()); |
|
| 216 | + define('AUTOPTIMIZE_WP_CONTENT_URL', content_url()); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches' , true ) ) { |
|
| 219 | + if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) { |
|
| 220 | 220 | $blog_id = get_current_blog_id(); |
| 221 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/' ); |
|
| 221 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/'); |
|
| 222 | 222 | } else { |
| 223 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
| 223 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
| 224 | 224 | } |
| 225 | - define('AUTOPTIMIZE_WP_ROOT_URL',str_replace(AUTOPTIMIZE_WP_CONTENT_NAME,'',AUTOPTIMIZE_WP_CONTENT_URL)); |
|
| 225 | + define('AUTOPTIMIZE_WP_ROOT_URL', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', AUTOPTIMIZE_WP_CONTENT_URL)); |
|
| 226 | 226 | |
| 227 | 227 | // Config element |
| 228 | 228 | $conf = autoptimizeConfig::instance(); |
| 229 | 229 | |
| 230 | 230 | // Choose the classes |
| 231 | 231 | $classes = array(); |
| 232 | - if($conf->get('autoptimize_js')) |
|
| 232 | + if ($conf->get('autoptimize_js')) |
|
| 233 | 233 | $classes[] = 'autoptimizeScripts'; |
| 234 | - if($conf->get('autoptimize_css')) |
|
| 234 | + if ($conf->get('autoptimize_css')) |
|
| 235 | 235 | $classes[] = 'autoptimizeStyles'; |
| 236 | - if($conf->get('autoptimize_html')) |
|
| 236 | + if ($conf->get('autoptimize_html')) |
|
| 237 | 237 | $classes[] = 'autoptimizeHTML'; |
| 238 | 238 | |
| 239 | 239 | // Set some options |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | ) |
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | - $content = apply_filters( 'autoptimize_filter_html_before_minify', $content ); |
|
| 265 | + $content = apply_filters('autoptimize_filter_html_before_minify', $content); |
|
| 266 | 266 | |
| 267 | 267 | // Run the classes |
| 268 | - foreach($classes as $name) { |
|
| 268 | + foreach ($classes as $name) { |
|
| 269 | 269 | $instance = new $name($content); |
| 270 | - if($instance->read($classoptions[$name])) { |
|
| 270 | + if ($instance->read($classoptions[$name])) { |
|
| 271 | 271 | $instance->minify(); |
| 272 | 272 | $instance->cache(); |
| 273 | 273 | $content = $instance->getcontent(); |
@@ -275,19 +275,19 @@ discard block |
||
| 275 | 275 | unset($instance); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $content = apply_filters( 'autoptimize_html_after_minify', $content ); |
|
| 278 | + $content = apply_filters('autoptimize_html_after_minify', $content); |
|
| 279 | 279 | return $content; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | -if ( autoptimizeCache::cacheavail() ) { |
|
| 282 | +if (autoptimizeCache::cacheavail()) { |
|
| 283 | 283 | $conf = autoptimizeConfig::instance(); |
| 284 | - if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') ) { |
|
| 284 | + if ($conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css')) { |
|
| 285 | 285 | // Hook to wordpress |
| 286 | 286 | if (defined('AUTOPTIMIZE_INIT_EARLIER')) { |
| 287 | - add_action('init','autoptimize_start_buffering',-1); |
|
| 287 | + add_action('init', 'autoptimize_start_buffering', -1); |
|
| 288 | 288 | } else { |
| 289 | 289 | if (!defined('AUTOPTIMIZE_HOOK_INTO')) { define('AUTOPTIMIZE_HOOK_INTO', 'template_redirect'); } |
| 290 | - add_action(constant("AUTOPTIMIZE_HOOK_INTO"),'autoptimize_start_buffering',2); |
|
| 290 | + add_action(constant("AUTOPTIMIZE_HOOK_INTO"), 'autoptimize_start_buffering', 2); |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | } else { |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | function autoptimize_activate() { |
| 298 | - register_uninstall_hook( __FILE__, 'autoptimize_uninstall' ); |
|
| 298 | + register_uninstall_hook(__FILE__, 'autoptimize_uninstall'); |
|
| 299 | 299 | } |
| 300 | -register_activation_hook( __FILE__, 'autoptimize_activate' ); |
|
| 300 | +register_activation_hook(__FILE__, 'autoptimize_activate'); |
|
| 301 | 301 | |
| 302 | 302 | include_once('classlesses/autoptimizeCacheChecker.php'); |
| 303 | 303 | |