From 286e155edfd4bb47212da8a7f7d66b8153530c46 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Sat, 14 Sep 2024 10:08:42 -0400 Subject: [PATCH 1/2] Local: ensure template assets use the correct port locally --- plugins/jquery-filters.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/jquery-filters.php b/plugins/jquery-filters.php index d4ed1510..3cbbe2d5 100644 --- a/plugins/jquery-filters.php +++ b/plugins/jquery-filters.php @@ -35,6 +35,16 @@ } unset( $sites, $options, $option ); +// Ensure that the local port is used for template assets, if it exists. +add_filter( 'theme_root_uri', function( $value ) { + 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 ); From 12bd35e7f5d7ee746ac8b1f883e614fda03e0a28 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Mon, 30 Sep 2024 21:34:35 -0400 Subject: [PATCH 2/2] fixup! add env var comment --- plugins/jquery-filters.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/jquery-filters.php b/plugins/jquery-filters.php index 3cbbe2d5..734810e3 100644 --- a/plugins/jquery-filters.php +++ b/plugins/jquery-filters.php @@ -37,6 +37,9 @@ // 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 ] );