diff --git a/plugins/jquery-filters.php b/plugins/jquery-filters.php index d4ed1510..734810e3 100644 --- a/plugins/jquery-filters.php +++ b/plugins/jquery-filters.php @@ -35,6 +35,19 @@ } unset( $sites, $options, $option ); +// Ensure that the local port is used for template assets, if it exists. +add_filter( 'theme_root_uri', function( $value ) { + // All environment variables are set either in the local wp-config.php or via puppet. + // Staging sites set JQUERY_STAGING to the boolean `true` instead of 'local'. + // Production sites set it to false. + if ( JQUERY_STAGING === 'local' ) { + // Don't specify http vs https here, as the site may be accessed via either. + $siteurl = '//' . strtr( JQUERY_STAGING_FORMAT, [ '%s' => JQUERY_LIVE_SITE ] ); + $value = $siteurl . '/wp-content/themes'; + } + return $value; +}); + // Remove misc links from on non-blog sites if ( !get_option( 'jquery_is_blog' ) ) { remove_action( 'wp_head', 'feed_links', 2 );