Permalink
Browse files

upstream's rollback of fixurl() changes in c753971 + changed expected…

… test hashes to match since 'wp-content' is back in urls now, which changes file contents etc...

introduced as part of upstream 1386e4f changes (which mentions getPath changes and nothing specific on
why fixurls also meddled with replacing/removing wp-content dir)
  • Loading branch information...
1 parent 9022bfc commit 51465c36b50173a662e46d6b033861d108c6b82a @zytzagoo committed May 12, 2017
Showing with 7 additions and 4 deletions.
  1. +5 −2 classes/autoptimizeStyles.php
  2. +2 −2 tests/test-ao.php
@@ -713,7 +713,8 @@ static function fixurls($file, $code)
if ( preg_match_all( self::ASSETS_REGEX, $code, $matches ) ) {
$file = str_replace( WP_ROOT_DIR, '/', $file );
- $file = str_replace( AUTOPTIMIZE_WP_CONTENT_NAME, '', $file );
+ // rollback as per https://github.com/futtta/autoptimize/issues/94
+ // $file = str_replace( AUTOPTIMIZE_WP_CONTENT_NAME, '', $file );
$dir = dirname( $file ); // Like /themes/expound/css
// $dir should not contain backslashes, since it's used to replace
@@ -743,7 +744,9 @@ static function fixurls($file, $code)
continue;
} else {
// Relative URL
- $newurl = preg_replace( '/https?:/', '', str_replace( ' ', '%20', AUTOPTIMIZE_WP_CONTENT_URL . str_replace( '//', '/', $dir . '/' . $url ) ) );
+ // rollback as per https://github.com/futtta/autoptimize/issues/94
+ // $newurl = preg_replace( '/https?:/', '', str_replace( ' ', '%20', AUTOPTIMIZE_WP_CONTENT_URL . str_replace( '//', '/', $dir . '/' . $url ) ) );
+ $newurl = preg_replace( '/https?:/', '', str_replace( ' ', '%20', AUTOPTIMIZE_WP_ROOT_URL . str_replace( '//', '/', $dir . '/' . $url ) ) );
// Hash the url + whatever was behind potentially for replacement
// We must do this, or different css classes referencing the same bg image (but
View
@@ -133,7 +133,7 @@ private function normalize_newlines($str)
<!--[if gt IE 8]><!--> <html class="no-svg no-js" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" lang="hr"> <!--<![endif]-->
<head>
<meta charset="utf-8">
-<link type="text/css" media="all" href="http://cdn.example.org/wp-content/cache/autoptimize/css/autoptimize_b14b273dfffdb2d292672833da60d3cb.css" rel="stylesheet" /><title>Mliječna juha od brokule &#9832; Kuhaj.hr</title>
+<link type="text/css" media="all" href="http://cdn.example.org/wp-content/cache/autoptimize/css/autoptimize_863f587e89f100b0223ddccc0dabc57a.css" rel="stylesheet" /><title>Mliječna juha od brokule &#9832; Kuhaj.hr</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<!--[if lt IE 9]>
@@ -178,7 +178,7 @@ private function normalize_newlines($str)
<!--[if gt IE 8]><!--> <html class="no-svg no-js" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" lang="hr"> <!--<![endif]-->
<head>
<meta charset="utf-8">
-<link type="text/css" media="all" href="http://cdn.example.org/wp-content/cache/autoptimize/1/css/autoptimize_b14b273dfffdb2d292672833da60d3cb.css" rel="stylesheet" /><title>Mliječna juha od brokule &#9832; Kuhaj.hr</title>
+<link type="text/css" media="all" href="http://cdn.example.org/wp-content/cache/autoptimize/1/css/autoptimize_863f587e89f100b0223ddccc0dabc57a.css" rel="stylesheet" /><title>Mliječna juha od brokule &#9832; Kuhaj.hr</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<!--[if lt IE 9]>

1 comment on commit 51465c3

futtta commented on 51465c3 May 13, 2017

indeed, was also surprised to see I did not document the reason for the fixurl() changes. i tried to trace back my reasoning, but couldn't see why i would have done that, so ... bad futtta!

Please sign in to comment.