PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
← All changes | config/autoptimize_404_handler.php +14 -3 2.7.7 → trunk View file →
@@ -28,13 +28,24 @@
28 28
29 29 $fallback_target = preg_replace( '/(.*)_(?:[a-z0-9]{32})\.(js|css)$/', '${1}_fallback.${2}', $original_request );
30 30 $ao_cache_dir = '<!--ao-cache-dir-->';
31 31 $js_or_css = pathinfo( $original_request, PATHINFO_EXTENSION );
32 -$fallback_path = $ao_cache_dir . $js_or_css . '/autoptimize_fallback.' . $js_or_css;
33 32
34 -if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
33 +// add multisite logic.
34 +$multisite = false;
35 +if ( true === $multisite ) {
36 + preg_match( '#\/([0-9]{1,5})\/(?:js|css)\/[a-z0-9]*_fallback\.(?:js|css)$#', $fallback_target, $child_site_id );
37 + $ao_root_cache_dir = preg_replace( '#[0-9]*\/$#', '', $ao_cache_dir );
38 + $ao_cache_dir = $ao_root_cache_dir . $child_site_id[1] . '/';
39 +}
40 +
41 +$fallback_path = $ao_cache_dir . $js_or_css . '/<!--ao-cachefile-prefix-->fallback.' . $js_or_css;
42 +
43 +if ( strpos( $fallback_target, '//' ) === 0 || strpos( $fallback_target, '/' ) !== 0 ) {
44 + exit();
45 +} else if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
35 46 // error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
36 - header( 'HTTP/1.1 301 Moved Permanently' );
47 + header( 'HTTP/1.1 302 Found' );
37 48 header( 'Location: ' . $fallback_target );
38 49 } else {
39 50 // error_log( 'Autoptimize file ' . $original_request . ' not found, sending 410 gone response.' );
40 51 header( 'HTTP/1.1 410 Gone' );