Commit ac335d2c84 for woocommerce

commit ac335d2c84b1748d5861193b73c8bdbaf190a38a
Author: Tony Arcangelini <33258733+arcangelini@users.noreply.github.com>
Date:   Wed Jan 21 17:01:28 2026 +0100

    Add woocommerce_email_editor_site_theme filter (#62889)

    * Add woocommerce_email_editor_site_theme filter

    Add a filter in Site_Style_Sync_Controller to allow overriding the site
    theme used when syncing global styles for the email editor. This is useful
    for environments where theme data is not directly accessible (e.g., wp.com
    Atomic and Jetpack sites).

    * Fix test

    * Fix test

    * Fix tests again

    * Add woocommerce_email_editor_site_theme filter to docs

    * fix(docs): add @docsearch/core dependency required for Docusaurus build

diff --git a/docs/_docu-tools/package.json b/docs/_docu-tools/package.json
index 9875d274b6..6594e7336f 100644
--- a/docs/_docu-tools/package.json
+++ b/docs/_docu-tools/package.json
@@ -17,6 +17,7 @@
     "typecheck": "tsc"
   },
   "dependencies": {
+    "@docsearch/core": "^4.5.2",
     "@docusaurus/core": "^3.9.2",
     "@docusaurus/faster": "^3.9.2",
     "@docusaurus/preset-classic": "^3.9.2",
diff --git a/packages/php/email-editor/README.md b/packages/php/email-editor/README.md
index 738ddfe0b9..ef9d7f16f5 100644
--- a/packages/php/email-editor/README.md
+++ b/packages/php/email-editor/README.md
@@ -103,6 +103,7 @@ We may add, update and delete any of them.
 | `woocommerce_email_editor_send_preview_email_personalizer_context` | `string` $content_styles, `WP_Post` $post` $personalizer_context | `Array` Personalizer context data                            | Allows modifying the personalizer context data for the send preview email function                                                                                     |
 | `woocommerce_email_editor_synced_site_styles`                      | `Array` $synced_data, `Array` $site_data                         | `Array` Modified synced data                                 | Used to filter the synced site style data before applying to email theme.                                                                                              |
 | `woocommerce_email_editor_site_style_sync_enabled`                 | `bool` $enabled                                                  | `bool`                                                       | Use to control whether site style sync functionality is enabled or disabled. Returning `false` will disable site theme sync.                                           |
+| `woocommerce_email_editor_site_theme`                              | `WP_Theme_JSON` $site_theme                                      | `WP_Theme_JSON`                                              | Modify the site theme before syncing styles to the email editor.                                                                                                       |
 | `woocommerce_email_editor_allowed_iframe_style_handles`            | `Array` $allowed_iframe_style_handles                            | `Array` $allowed_iframe_style_handles                        | Filter the list of allowed stylesheet handles in the editor iframe.                                                                                                    |
 | `woocommerce_email_editor_script_localization_data`                | `Array` $localization_data                                       | `Array` $localization_data                                   | Use to modify inlined JavaScript variables used by Email Editor client.                                                                                                |
 | `woocommerce_email_editor_styles_unsupported_props`                | `Array` $unsupported_props                                       | `Array` $unsupported_props                                   | Filter the list of unsupported style properties (as nested key paths) that will be removed before block styles are converted to CSS.                                   |
diff --git a/packages/php/email-editor/changelog/add-site-theme-filter b/packages/php/email-editor/changelog/add-site-theme-filter
new file mode 100644
index 0000000000..b2d9f68301
--- /dev/null
+++ b/packages/php/email-editor/changelog/add-site-theme-filter
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Add woocommerce_email_editor_site_theme filter to allow overriding the site theme used when syncing global styles for the email editor.
diff --git a/packages/php/email-editor/docs/site-style-sync-hooks.md b/packages/php/email-editor/docs/site-style-sync-hooks.md
index 67eb34ca4a..03a9a14f68 100644
--- a/packages/php/email-editor/docs/site-style-sync-hooks.md
+++ b/packages/php/email-editor/docs/site-style-sync-hooks.md
@@ -75,6 +75,40 @@ add_filter( 'woocommerce_email_editor_site_style_sync_enabled', function( $enabl
 });
 ```

+### `woocommerce_email_editor_site_theme`
+
+Filter the site theme data used for email style sync.
+
+This filter allows overriding the site theme used when syncing global styles for the email editor. Useful for environments where theme data is not directly accessible (e.g., wp.com Atomic and Jetpack sites).
+
+```php
+/**
+ * Filter the site theme data used for email style sync.
+ *
+ * @since 2.3.0
+ * @param WP_Theme_JSON $site_theme The site theme data.
+ * @return WP_Theme_JSON Modified site theme data.
+ */
+apply_filters( 'woocommerce_email_editor_site_theme', $site_theme );
+```
+
+**Example Usage:**
+
+```php
+// Override the site theme with custom theme data for environments
+// where theme data is not directly accessible
+add_filter( 'woocommerce_email_editor_site_theme', function( $site_theme ) {
+    // Fetch theme data from an external source
+    $custom_theme_data = get_custom_theme_data();
+
+    if ( $custom_theme_data ) {
+        return new WP_Theme_JSON( $custom_theme_data, 'custom' );
+    }
+
+    return $site_theme;
+});
+```
+
 ## Advanced Customization Examples

 ### Custom Font Mapping
diff --git a/packages/php/email-editor/src/Engine/class-site-style-sync-controller.php b/packages/php/email-editor/src/Engine/class-site-style-sync-controller.php
index 3fc96cd06e..9bb52feeae 100644
--- a/packages/php/email-editor/src/Engine/class-site-style-sync-controller.php
+++ b/packages/php/email-editor/src/Engine/class-site-style-sync-controller.php
@@ -136,6 +136,19 @@ class Site_Style_Sync_Controller {
 			$this->site_theme->merge( WP_Theme_JSON_Resolver::get_theme_data() );
 			$this->site_theme->merge( WP_Theme_JSON_Resolver::get_user_data() );

+			/**
+			 * Filter the site theme data used for email style sync.
+			 *
+			 * This filter allows overriding the site theme used when syncing global styles
+			 * for the email editor. Useful for environments where theme data is not directly
+			 * accessible (e.g., wp.com Atomic and Jetpack sites).
+			 *
+			 * @since 2.3.0
+			 *
+			 * @param WP_Theme_JSON $site_theme The site theme data.
+			 */
+			$this->site_theme = apply_filters( 'woocommerce_email_editor_site_theme', $this->site_theme );
+
 			if ( isset( $this->site_theme->get_raw_data()['styles'] ) ) {
 				$this->site_theme = WP_Theme_JSON::resolve_variables( $this->site_theme );
 			}
diff --git a/packages/php/email-editor/tests/integration/Engine/Site_Style_Sync_Controller_Test.php b/packages/php/email-editor/tests/integration/Engine/Site_Style_Sync_Controller_Test.php
index 94895b9735..04b9bf0f4a 100644
--- a/packages/php/email-editor/tests/integration/Engine/Site_Style_Sync_Controller_Test.php
+++ b/packages/php/email-editor/tests/integration/Engine/Site_Style_Sync_Controller_Test.php
@@ -784,6 +784,69 @@ class Site_Style_Sync_Controller_Test extends \Email_Editor_Integration_Test_Cas
 		$this->assertEquals( '#007cba', $synced_data['styles']['elements']['button']['color']['background'] );
 	}

+	/**
+	 * Test site theme filter is applied.
+	 */
+	public function test_site_theme_filter_is_applied(): void {
+		// Add filter to override site theme.
+		add_filter(
+			'woocommerce_email_editor_site_theme',
+			function ( $site_theme ) {
+				$new_site_theme = new WP_Theme_JSON(
+					array(
+						'version'  => 3,
+						'settings' => array(
+							'color' => array(
+								'palette' => array(
+									'theme'  => array(
+										array(
+											'slug'  => 'theme-color',
+											'color' => '#00ff00',
+											'name'  => 'Theme Color',
+										),
+									),
+									'custom' => array(
+										array(
+											'slug'  => 'custom-color',
+											'color' => '#ff0000',
+											'name'  => 'Custom Color',
+										),
+									),
+								),
+							),
+						),
+						'styles'   => array(),
+					),
+					'theme'
+				);
+
+				$site_theme->merge( $new_site_theme );
+				return $site_theme;
+			},
+			10,
+			1
+		);
+
+		$synced_data = $this->controller->sync_site_styles();
+
+		// Find colors by slug.
+		$palette      = $synced_data['settings']['color']['palette'];
+		$theme_index  = array_search( 'theme-color', array_column( $palette, 'slug' ), true );
+		$custom_index = array_search( 'custom-color', array_column( $palette, 'slug' ), true );
+
+		// Verify filter was applied.
+		$this->assertNotFalse( $theme_index, 'Theme color should exist in palette' );
+		$this->assertEquals( '#00ff00', $palette[ $theme_index ]['color'] );
+		$this->assertEquals( 'Theme Color', $palette[ $theme_index ]['name'] );
+
+		$this->assertNotFalse( $custom_index, 'Custom color should exist in palette' );
+		$this->assertEquals( '#ff0000', $palette[ $custom_index ]['color'] );
+		$this->assertEquals( 'Custom Color', $palette[ $custom_index ]['name'] );
+
+		// Clean up.
+		remove_all_filters( 'woocommerce_email_editor_site_theme' );
+	}
+
 	/**
 	 * Test reference pointing to non-existing path should result in null.
 	 */