Skip to content

Commit 6b33d87

Browse files
committed
All: add option filter to prevent local homepage redirects
1 parent c9f5b50 commit 6b33d87

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mu-plugins/jquery-filters.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@ function strip_https($url) {
120120

121121
return preg_replace( '/^https?:/', '', $url );
122122
}
123+
124+
// Production databases set the home values in corresponding site options tables.
125+
// However, sites that use jquery-static-index.php cause index pages
126+
// to redirect to live sites in local development. This filter does not
127+
// prevent the redirect, but changes the redirect to the local site.
128+
if (JQUERY_STAGING && JQUERY_STAGING_PREFIX && JQUERY_LIVE_SITE) {
129+
add_filter( 'option_home', function( $value ) {
130+
return str_replace( '//' . JQUERY_LIVE_SITE, '//' . JQUERY_STAGING_PREFIX . JQUERY_LIVE_SITE, $value );
131+
} );
132+
}

0 commit comments

Comments
 (0)