Skip to content

Commit 12f7a3a

Browse files
authored
Local: ensure template assets use the correct port locally
Closes gh-466
1 parent 7711bf5 commit 12f7a3a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

plugins/jquery-filters.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
}
3636
unset( $sites, $options, $option );
3737

38+
// Ensure that the local port is used for template assets, if it exists.
39+
add_filter( 'theme_root_uri', function( $value ) {
40+
// All environment variables are set either in the local wp-config.php or via puppet.
41+
// Staging sites set JQUERY_STAGING to the boolean `true` instead of 'local'.
42+
// Production sites set it to false.
43+
if ( JQUERY_STAGING === 'local' ) {
44+
// Don't specify http vs https here, as the site may be accessed via either.
45+
$siteurl = '//' . strtr( JQUERY_STAGING_FORMAT, [ '%s' => JQUERY_LIVE_SITE ] );
46+
$value = $siteurl . '/wp-content/themes';
47+
}
48+
return $value;
49+
});
50+
3851
// Remove misc links from <head> on non-blog sites
3952
if ( !get_option( 'jquery_is_blog' ) ) {
4053
remove_action( 'wp_head', 'feed_links', 2 );

0 commit comments

Comments
 (0)