From 1f49494c366d5c7fb7922c52d5e7eb4b5c8ddd98 Mon Sep 17 00:00:00 2001 From: Nick Daugherty Date: Thu, 4 Feb 2021 16:38:41 -0700 Subject: [PATCH] Always filter the jetpack_https_transient to 1 Outbound SSL is always available on VIP so we can avoid unnecessary HTTP requests from JP while trying to determine this props @emrikol for the idea + code --- tests/test-vip-jetpack.php | 8 ++++++++ vip-jetpack/vip-jetpack.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/test-vip-jetpack.php b/tests/test-vip-jetpack.php index 71a8997030..a873224f04 100644 --- a/tests/test-vip-jetpack.php +++ b/tests/test-vip-jetpack.php @@ -160,4 +160,12 @@ public function test__jetpack_sync_modules__class_exists( $modules, $expected_mo $this->assertEquals( $expected_modules, $actual_modules ); } + + public function test__jetpack_https_test__transient_filter() { + $https_test = apply_filters( 'pre_transient_jetpack_https_test', null ); + $https_test_message = apply_filters( 'pre_transient_jetpack_https_test_message', null ); + + $this->assertEquals( 1, $https_test, 'Value of the jetpack_https_test pre-transient filter is incorrect' ); + $this->assertEquals( '', $https_test_message, 'Value of the jetpack_https_test_message pre-transient filter is incorrect' ); + } } diff --git a/vip-jetpack/vip-jetpack.php b/vip-jetpack/vip-jetpack.php index 206c23b90a..1b082ce762 100644 --- a/vip-jetpack/vip-jetpack.php +++ b/vip-jetpack/vip-jetpack.php @@ -380,3 +380,9 @@ function vip_jetpack_admin_enqueue_scripts() { // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found return defined( 'VIP_DISABLE_JETPACK_SYNC_CHECKSUM' ) && VIP_DISABLE_JETPACK_SYNC_CHECKSUM ?: $value; }, 10, 3 ); + +/** + * SSL is always supported on VIP, so avoid unnecessary checks + */ +add_filter( 'pre_transient_jetpack_https_test', function() { return 1; } ); // WP doesn't have __return_one (but it does have __return_zero) +add_filter( 'pre_transient_jetpack_https_test_message', '__return_empty_string' );