From ad3bc2343626d3fc000438dabcc7041721937fac Mon Sep 17 00:00:00 2001 From: Taha Paksu <3295+tpaksu@users.noreply.github.com> Date: Fri, 29 Dec 2023 13:36:23 +0300 Subject: [PATCH 1/2] Add theme name to compatibility service --- changelog/add-3943-send-blog-theme-to-sift | 4 ++++ includes/class-compatibility-service.php | 1 + tests/unit/test-class-compatibility-service.php | 9 +++++++++ 3 files changed, 14 insertions(+) create mode 100644 changelog/add-3943-send-blog-theme-to-sift diff --git a/changelog/add-3943-send-blog-theme-to-sift b/changelog/add-3943-send-blog-theme-to-sift new file mode 100644 index 00000000000..7f67989d63f --- /dev/null +++ b/changelog/add-3943-send-blog-theme-to-sift @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add the active theme name of the blog to the compatibility service diff --git a/includes/class-compatibility-service.php b/includes/class-compatibility-service.php index 444b3383cb1..c2744e8fa28 100644 --- a/includes/class-compatibility-service.php +++ b/includes/class-compatibility-service.php @@ -52,6 +52,7 @@ public function update_compatibility_data() { [ 'woopayments_version' => WCPAY_VERSION_NUMBER, 'woocommerce_version' => WC_VERSION, + 'blog_theme' => get_stylesheet(), ] ); } catch ( API_Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch diff --git a/tests/unit/test-class-compatibility-service.php b/tests/unit/test-class-compatibility-service.php index 70e86b5d2dc..99a279233c1 100644 --- a/tests/unit/test-class-compatibility-service.php +++ b/tests/unit/test-class-compatibility-service.php @@ -43,10 +43,19 @@ public function test_registers_woocommerce_filters_properly() { } public function test_update_compatibility_data() { + $stylesheet = 'my_theme_name'; + add_filter( + 'stylesheet', + function( $theme ) use ( $stylesheet ) { + return $stylesheet; + } + ); + // Arrange: Create the expected value to be passed to update_compatibility_data. $expected = [ 'woopayments_version' => WCPAY_VERSION_NUMBER, 'woocommerce_version' => WC_VERSION, + 'blog_theme' => $stylesheet, ]; // Arrange/Assert: Set the expectations for update_compatibility_data. From 66369ce2f89f00c805680e7079d0e354ac1a3ec1 Mon Sep 17 00:00:00 2001 From: Taha Paksu <3295+tpaksu@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:45:21 +0300 Subject: [PATCH 2/2] Update compatibility data after theme is switched --- includes/class-compatibility-service.php | 1 + tests/unit/test-class-compatibility-service.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/includes/class-compatibility-service.php b/includes/class-compatibility-service.php index c2744e8fa28..d258b0f740e 100644 --- a/includes/class-compatibility-service.php +++ b/includes/class-compatibility-service.php @@ -39,6 +39,7 @@ public function __construct( WC_Payments_API_Client $payments_api_client ) { */ public function init_hooks() { add_action( 'woocommerce_payments_account_refreshed', [ $this, 'update_compatibility_data' ] ); + add_action( 'after_switch_theme', [ $this, 'update_compatibility_data' ] ); } /** diff --git a/tests/unit/test-class-compatibility-service.php b/tests/unit/test-class-compatibility-service.php index 99a279233c1..0e5cfa53b0a 100644 --- a/tests/unit/test-class-compatibility-service.php +++ b/tests/unit/test-class-compatibility-service.php @@ -40,6 +40,8 @@ public function set_up() { public function test_registers_woocommerce_filters_properly() { $priority = has_filter( 'woocommerce_payments_account_refreshed', [ $this->compatibility_service, 'update_compatibility_data' ] ); $this->assertEquals( 10, $priority ); + $priority = has_action( 'after_switch_theme', [ $this->compatibility_service, 'update_compatibility_data' ] ); + $this->assertEquals( 10, $priority ); } public function test_update_compatibility_data() {