PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / trunk
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score vtrunk
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
← All changes | includes/classes/Optimizer/JS.php +7 -5 2.0.3trunk View file →
@@ -84,8 +84,9 @@
84 84 *
85 85 * @return array|string[]
86 86 */
87 87 public function do_items( $handles = false, $group = false ) {
88 + $abspath = wp_normalize_path( ABSPATH );
88 89 $handles = false === $handles ? $this->queue : (array) $handles;
89 90 $javascripts = array();
90 91 $siteurl = apply_filters( 'powered_cache_fo_site_url', $this->base_url );
91 92
@@ -134,13 +135,14 @@
134 135 }
135 136
136 137 // Concat and canonicalize the paths only for
137 138 // existing scripts that aren't outside ABSPATH
139 +
138 140 $js_realpath = Helper::realpath( $js_url, $siteurl );
139 - if ( ! $js_realpath || 0 !== strpos( $js_realpath, ABSPATH ) ) {
141 + if ( ! $js_realpath || 0 !== strpos( $js_realpath, $abspath ) ) {
140 142 $do_concat = false;
141 143 } else {
142 - $js_url_parsed['path'] = substr( $js_realpath, strlen( ABSPATH ) - 1 );
144 + $js_url_parsed['path'] = substr( $js_realpath, strlen( $abspath ) - 1 );
143 145 }
144 146
145 147 if ( $this->has_inline_content( $handle ) ) {
146 148 $do_concat = false;
@@ -198,15 +200,15 @@
198 200 array_map( array( $this, 'print_extra_script' ), $js_array['handles'] );
199 201
200 202 if ( isset( $js_array['paths'] ) && count( $js_array['paths'] ) > 1 ) {
201 203 $paths = array_map(
202 - function ( $url ) {
203 - return ABSPATH . $url;
204 + function ( $url ) use ( $abspath ) {
205 + return $abspath . $url;
204 206 },
205 207 $js_array['paths']
206 208 );
207 209 $mtime = max( array_map( 'filemtime', $paths ) );
208 - $path_str = implode( ',', $js_array['paths'] ) . "?m=${mtime}j";
210 + $path_str = implode( ',', $js_array['paths'] ) . "?m={$mtime}j";
209 211
210 212 if ( $this->allow_gzip_compression ) {
211 213 $path_64 = base64_encode( gzcompress( $path_str ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
212 214 if ( strlen( $path_str ) > ( strlen( $path_64 ) + 1 ) ) {