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..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' ] ); } /** @@ -52,6 +53,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..0e5cfa53b0a 100644 --- a/tests/unit/test-class-compatibility-service.php +++ b/tests/unit/test-class-compatibility-service.php @@ -40,13 +40,24 @@ 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() { + $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.