Skip to content

Commit

Permalink
misc. fixes for issues in 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
futtta committed Mar 14, 2016
1 parent fa46052 commit 5ecb5a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion classes/autoptimizeCache.php
Expand Up @@ -94,7 +94,7 @@ function autoptimize_do_cachepurged_action() {
do_action("autoptimize_action_cachepurged");
}
}
add_action("plugins_loaded","autoptimize_do_cachepurged_action",11);
add_action("after_theme_setup","autoptimize_do_cachepurged_action",11);

// try to purge caching plugins cache-files?
include_once(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizePageCacheFlush.php');
Expand Down
2 changes: 1 addition & 1 deletion classes/autoptimizeScripts.php
Expand Up @@ -346,7 +346,7 @@ private function ismergeable($tag) {

//Checks agains the blacklist
private function ismovable($tag) {
if ($this->include_inline !== true || apply_filters('autoptimize_filter_js_unmovable',false)) {
if ($this->include_inline !== true || apply_filters('autoptimize_filter_js_unmovable',true)) {
return false;
}

Expand Down
8 changes: 3 additions & 5 deletions classes/autoptimizeStyles.php
Expand Up @@ -391,12 +391,10 @@ public function minify() {
}

// CDN the fonts!
if ((!empty($this->cdn_url))&&apply_filters("autoptimize_filter_css_fonts_cdn",false)) {
if ( (!empty($this->cdn_url)) && (apply_filters('autoptimize_filter_css_fonts_cdn',false)) && (version_compare(PHP_VERSION, '5.3.0') >= 0) ) {
$fontreplace = array();
$fonturl_regex = <<<'LOD'
~(?(DEFINE)(?<quoted_content>(["']) (?>[^"'\\]++ | \\{2} | \\. | (?!\g{-1})["'] )*+ \g{-1})(?<comment> /\* .*? \*/ ) (?<url_skip>(?: data: ) [^"'\s)}]*+ ) (?<other_content>(?> [^u}/"']++ | \g<quoted_content> | \g<comment> | \Bu | u(?!rl\s*+\() | /(?!\*) | \g<url_start> \g<url_skip> ["']?+ )++ ) (?<anchor> \G(?<!^) ["']?+ | @font-face \s*+ { ) (?<url_start> url\( \s*+ ["']?+ ) ) \g<comment> (*SKIP)(*FAIL) | \g<anchor> \g<other_content>?+ \g<url_start> \K ((?:(?:https?:)?(?://[[:alnum:]\-\.]+)(?::[0-9]+)?)?\/[^"'\s)}]*+) ~xs
LOD;

include_once(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeFontRegex.php');

preg_match_all($fonturl_regex,$code,$matches);
if (is_array($matches)) {
foreach($matches[8] as $count => $quotedurl) {
Expand Down
9 changes: 9 additions & 0 deletions classlesses/autoptimizeFontRegex.php
@@ -0,0 +1,9 @@
<?php
// regex to find fonts, externalised to avoid nasty errors for php<5.3

$fonturl_regex = <<<'LOD'
~(?(DEFINE)(?<quoted_content>(["']) (?>[^"'\\]++ | \\{2} | \\. | (?!\g{-1})["'] )*+ \g{-1})(?<comment> /\* .*? \*/ ) (?<url_skip>(?: data: ) [^"'\s)}]*+ ) (?<other_content>(?> [^u}/"']++ | \g<quoted_content> | \g<comment> | \Bu | u(?!rl\s*+\() | /(?!\*) | \g<url_start> \g<url_skip> ["']?+ )++ ) (?<anchor> \G(?<!^) ["']?+ | @font-face \s*+ { ) (?<url_start> url\( \s*+ ["']?+ ) ) \g<comment> (*SKIP)(*FAIL) | \g<anchor> \g<other_content>?+ \g<url_start> \K ((?:(?:https?:)?(?://[[:alnum:]\-\.]+)(?::[0-9]+)?)?\/[^"'\s)}]*+) ~xs
LOD;

error_log('fontregex included');
?>

0 comments on commit 5ecb5a1

Please sign in to comment.