Commit 19603d19aca for woocommerce

commit 19603d19acaf62d9fc8cd900de4f7e90ad153535
Author: Luigi Teschio <gigitux@gmail.com>
Date:   Tue Jun 2 11:23:35 2026 +0200

    Remove coming soon newsletter template flag (#65461)

diff --git a/plugins/woocommerce-beta-tester/userscripts/wc-live-branches.user.js b/plugins/woocommerce-beta-tester/userscripts/wc-live-branches.user.js
index 57a53a5824d..3b73d46d1ac 100644
--- a/plugins/woocommerce-beta-tester/userscripts/wc-live-branches.user.js
+++ b/plugins/woocommerce-beta-tester/userscripts/wc-live-branches.user.js
@@ -170,7 +170,6 @@
 		} else {
 			// TODO: Fetch the list of feature flags dynamically from the API or something.
 			const featureFlags = [
-				'coming-soon-newsletter-template',
 				'launch-your-store',
 				'minified-js',
 				'product-custom-fields',
diff --git a/plugins/woocommerce/changelog/remove-coming-soon-newsletter-template-flag b/plugins/woocommerce/changelog/remove-coming-soon-newsletter-template-flag
new file mode 100644
index 00000000000..df33faf2fdd
--- /dev/null
+++ b/plugins/woocommerce/changelog/remove-coming-soon-newsletter-template-flag
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Remove the unused coming soon newsletter template feature flag.
diff --git a/plugins/woocommerce/client/admin/client/typings/global.d.ts b/plugins/woocommerce/client/admin/client/typings/global.d.ts
index 4b633e4f2fd..dc8fbcd9b30 100644
--- a/plugins/woocommerce/client/admin/client/typings/global.d.ts
+++ b/plugins/woocommerce/client/admin/client/typings/global.d.ts
@@ -52,7 +52,6 @@ declare global {
 			'analytics-scheduled-import': boolean;
 			'activity-panels': boolean;
 			analytics: boolean;
-			'coming-soon-newsletter-template': boolean;
 			coupons: boolean;
 			'customer-effort-score-tracks': boolean;
 			homescreen: boolean;
diff --git a/plugins/woocommerce/client/admin/config/core.json b/plugins/woocommerce/client/admin/config/core.json
index c33a84a26e6..4f274839de6 100644
--- a/plugins/woocommerce/client/admin/config/core.json
+++ b/plugins/woocommerce/client/admin/config/core.json
@@ -7,7 +7,6 @@
 		"product-data-views": false,
 		"experimental-blocks": false,
 		"experimental-iapi-mini-cart": true,
-		"coming-soon-newsletter-template": false,
 		"coupons": true,
 		"core-profiler": true,
 		"customize-store": true,
diff --git a/plugins/woocommerce/client/admin/config/development.json b/plugins/woocommerce/client/admin/config/development.json
index 94147a04818..31a94d4ba4d 100644
--- a/plugins/woocommerce/client/admin/config/development.json
+++ b/plugins/woocommerce/client/admin/config/development.json
@@ -7,7 +7,6 @@
 		"product-data-views": false,
 		"experimental-blocks": true,
 		"experimental-iapi-mini-cart": true,
-		"coming-soon-newsletter-template": false,
 		"coupons": true,
 		"core-profiler": true,
 		"customize-store": true,
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/index.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/index.tsx
index 627bc3f15d8..592f0a96581 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/index.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/index.tsx
@@ -3,7 +3,6 @@
  */
 import { __ } from '@wordpress/i18n';
 import { registerBlockType } from '@wordpress/blocks';
-import { registerPlugin } from '@wordpress/plugins';

 /**
  * Internal dependencies
@@ -12,7 +11,6 @@ import Edit from './edit';
 import Save from './save';
 import metadata from './block.json';
 import deprecated from './deprecated';
-import NewsletterPanel from './newsletter-panel';
 import './store-only.scss';
 import './entire-site.scss';

@@ -23,10 +21,3 @@ registerBlockType( metadata, {
 	apiVersion: 3,
 	deprecated,
 } );
-
-if ( typeof window.comingSoonNewsletter !== 'undefined' ) {
-	registerPlugin( 'plugin-coming-soon-newsletter-setting-panel', {
-		render: NewsletterPanel,
-		icon: 'palmtree',
-	} );
-}
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.scss
deleted file mode 100644
index 7ec77f13561..00000000000
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.scss
+++ /dev/null
@@ -1,13 +0,0 @@
-.coming-soon-newsletter-mailpoet-setting-panel-body {
-	background-color: #f1f6fc;
-	padding: 15px;
-
-	h3 {
-		text-transform: none;
-		font-size: 13px;
-	}
-
-	a.components-button.is-link {
-		text-decoration: none;
-	}
-}
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.tsx
deleted file mode 100644
index acf2866e0c0..00000000000
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/coming-soon/newsletter-panel.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * External dependencies
- */
-import { useSelect } from '@wordpress/data';
-import { __ } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
-import { getAdminLink } from '@woocommerce/settings';
-import { PluginDocumentSettingPanel } from '@wordpress/editor';
-/**
- * Internal dependencies
- */
-import './newsletter-panel.scss';
-
-const NewsletterPanel = () => {
-	const postId = useSelect( ( select ) =>
-		select( 'core/editor' ).getCurrentPostId()
-	);
-
-	// Restrict the panel to only show on the coming soon page template.
-	if ( typeof postId === 'string' && ! postId?.endsWith( '//coming-soon' ) ) {
-		return null;
-	}
-
-	// For whatever reason,  if PluginDocumentSettingPanel is not available, abort.
-	if ( ! PluginDocumentSettingPanel ) {
-		return null;
-	}
-
-	// comingSoonNewsletter is set up from LaunchYourStore.php
-	// eslint-disable-next-line
-	const { mailpoet_connected, mailpoet_installed } =
-		window.comingSoonNewsletter || {};
-
-	// If MailPoet is connected, don't show the panel
-	if ( mailpoet_connected ) {
-		return null;
-	}
-
-	// If MailPoet is not installed, link to the plugin install page.
-	// Otherwise, link to the MailPoet homepage to connect.
-	const setupLink = ! mailpoet_installed
-		? getAdminLink(
-				'plugin-install.php?tab=plugin-information&plugin=mailpoet'
-		  )
-		: getAdminLink( 'admin.php?page=mailpoet-homepage' );
-
-	return (
-		<PluginDocumentSettingPanel
-			name="coming-soon-newsletter-mailpoet-setting-panel"
-			title={ __( 'Launch Newsletter', 'woocommerce' ) }
-			className="coming-soon-newsletter-mailpoet-setting-panel"
-		>
-			<div className="coming-soon-newsletter-mailpoet-setting-panel-body">
-				<h3>{ __( 'Set up email marketing', 'woocommerce' ) }</h3>
-				<p>
-					{ __(
-						'To collect email and notify your subscribers, set up MailPoet.',
-						'woocommerce'
-					) }
-				</p>
-				<Button variant="link" href={ setupLink }>
-					{ __( 'Set up MailPoet', 'woocommerce' ) }
-				</Button>
-			</div>
-		</PluginDocumentSettingPanel>
-	);
-};
-
-export default NewsletterPanel;
diff --git a/plugins/woocommerce/client/blocks/assets/js/global.d.ts b/plugins/woocommerce/client/blocks/assets/js/global.d.ts
index ef422dc3dda..12cbebc2079 100644
--- a/plugins/woocommerce/client/blocks/assets/js/global.d.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/global.d.ts
@@ -1,11 +1,2 @@
 // eslint-disable-next-line camelcase
 declare let __webpack_public_path__: string;
-
-declare global {
-	interface Window {
-		comingSoonNewsletter: {
-			mailpoet_installed: boolean;
-			mailpoet_connected: boolean;
-		};
-	}
-}
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 24191cfac91..0eee3ac5f63 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -46611,24 +46611,6 @@ parameters:
 			count: 2
 			path: src/Admin/Features/LaunchYourStore.php

-		-
-			message: '#^Access to property \$post_content on an unknown class Automattic\\WooCommerce\\Admin\\Features\\WP_Post\.$#'
-			identifier: class.notFound
-			count: 1
-			path: src/Admin/Features/LaunchYourStore.php
-
-		-
-			message: '#^Access to property \$post_name on an unknown class Automattic\\WooCommerce\\Admin\\Features\\WP_Post\.$#'
-			identifier: class.notFound
-			count: 2
-			path: src/Admin/Features/LaunchYourStore.php
-
-		-
-			message: '#^Access to property \$post_title on an unknown class Automattic\\WooCommerce\\Admin\\Features\\WP_Post\.$#'
-			identifier: class.notFound
-			count: 2
-			path: src/Admin/Features/LaunchYourStore.php
-
 		-
 			message: '#^Callback expects 1 parameter, \$accepted_args is set to 2\.$#'
 			identifier: arguments.count
@@ -46641,12 +46623,6 @@ parameters:
 			count: 1
 			path: src/Admin/Features/LaunchYourStore.php

-		-
-			message: '#^Method Automattic\\WooCommerce\\Admin\\Features\\LaunchYourStore\:\:maybe_track_template_change\(\) has no return type specified\.$#'
-			identifier: missingType.return
-			count: 1
-			path: src/Admin/Features/LaunchYourStore.php
-
 		-
 			message: '#^Method Automattic\\WooCommerce\\Admin\\Features\\LaunchYourStore\:\:register_launch_your_store_user_meta_fields\(\) has no return type specified\.$#'
 			identifier: missingType.return
@@ -46659,24 +46635,6 @@ parameters:
 			count: 1
 			path: src/Admin/Features/LaunchYourStore.php

-		-
-			message: '#^Parameter \$post of method Automattic\\WooCommerce\\Admin\\Features\\LaunchYourStore\:\:maybe_track_template_change\(\) has invalid type Automattic\\WooCommerce\\Admin\\Features\\WP_Post\.$#'
-			identifier: class.notFound
-			count: 1
-			path: src/Admin/Features/LaunchYourStore.php
-
-		-
-			message: '#^Property WP_Post\:\:\$post_name \(string\) in isset\(\) is not nullable\.$#'
-			identifier: isset.property
-			count: 1
-			path: src/Admin/Features/LaunchYourStore.php
-
-		-
-			message: '#^Property WP_Post\:\:\$post_title \(string\) in isset\(\) is not nullable\.$#'
-			identifier: isset.property
-			count: 1
-			path: src/Admin/Features/LaunchYourStore.php
-
 		-
 			message: '#^Argument of an invalid type array\|null supplied for foreach, only iterables are supported\.$#'
 			identifier: foreach.nonIterable
diff --git a/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php b/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php
index 1eb53036c8a..72d598042af 100644
--- a/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php
+++ b/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php
@@ -2,7 +2,6 @@

 namespace Automattic\WooCommerce\Admin\Features;

-use Automattic\WooCommerce\Admin\PluginsHelper;
 use Automattic\WooCommerce\Admin\WCAdminHelper;
 use Automattic\WooCommerce\Internal\Admin\WCAdminUser;

@@ -23,10 +22,6 @@ class LaunchYourStore {
 		add_filter( 'woocommerce_tracks_event_properties', array( $this, 'append_coming_soon_global_tracks' ), 10, 2 );
 		add_action( 'wp_login', array( $this, 'reset_woocommerce_coming_soon_banner_dismissed' ), 10, 2 );
 		add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
-		if ( Features::is_enabled( 'coming-soon-newsletter-template' ) ) {
-			add_action( 'admin_enqueue_scripts', array( $this, 'load_newsletter_scripts' ) );
-			add_action( 'save_post_wp_template', array( $this, 'maybe_track_template_change' ), 10, 3 );
-		}
 	}

 	/**
@@ -268,90 +263,4 @@ class LaunchYourStore {
 			WCAdminUser::update_user_data_field( $user->ID, self::BANNER_DISMISS_USER_META_KEY, 'no' );
 		}
 	}
-
-	/**
-	 * Check if the Mailpoet is connected.
-	 *
-	 * @return bool true if Mailpoet is fully connected, meaning the API key is valid and approved.
-	 */
-	private function is_mailpoet_connected() {
-		if ( ! class_exists( '\MailPoet\DI\ContainerWrapper' ) || ! class_exists( '\MailPoet\Settings\SettingsController' ) ) {
-			return false;
-		}
-
-		$container = \MailPoet\DI\ContainerWrapper::getInstance( WP_DEBUG );
-
-		// SettingController retrieves data from wp_mailpoet_settings table.
-		$settings = $container->get( \MailPoet\Settings\SettingsController::class );
-
-		if ( false === $settings instanceof \MailPoet\Settings\SettingsController ) {
-			return false;
-		}
-
-		$mta       = $settings->get( 'mta' );
-		$api_state = $mta['mailpoet_api_key_state'] ?? null;
-
-		if ( ! $api_state || ! isset( $api_state['state'], $api_state['code'] ) ) {
-			return false;
-		}
-
-		return 'valid' === $api_state['state'] && 200 === $api_state['code'];
-	}
-
-	/**
-	 * Track when coming soon template is changed.
-	 *
-	 * @param int     $post_id The post ID.
-	 * @param WP_Post $post The post object.
-	 * @param bool    $update Whether the post is being updated.
-	 */
-	public function maybe_track_template_change( $post_id, $post, $update ) {
-		if ( ! $post instanceof \WP_Post || ! isset( $post->post_name, $post->post_title ) ) {
-			return;
-		}
-
-		// Check multiple fields to avoid false matches with non-WooCommerce templates.
-		if ( 'coming-soon' === $post->post_name && 'Page: Coming soon' === $post->post_title ) {
-			$matches = array();
-			$content = $post->post_content;
-			preg_match( '/"comingSoonPatternId":"([^"]+)"/', $content, $matches );
-
-			if ( isset( $matches[1] ) ) {
-				wc_admin_record_tracks_event(
-					'coming_soon_template_saved',
-					array(
-						'pattern_id' => $matches[1],
-						'is_update'  => $update,
-					)
-				);
-			}
-		}
-	}
-
-	/**
-	 * Load slotfill script and JS variables for the newsletter.
-	 * The comingSoonNewsletter is used in client/wp-admin-scripts/coming-soon-newsletter-panel
-	 *
-	 * @return void
-	 */
-	public function load_newsletter_scripts() {
-		$screen = get_current_screen();
-		if ( ! $screen instanceof \WP_Screen ) {
-			return;
-		}
-
-		if ( 'site-editor' !== $screen->id ) {
-			return;
-		}
-
-		$mailpoet = array(
-			'mailpoet_installed' => PluginsHelper::is_plugin_installed( 'mailpoet' ),
-			'mailpoet_connected' => $this->is_mailpoet_connected(),
-		);
-
-		// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion, WordPress.WP.EnqueuedResourceParameters.NotInFooter
-		wp_register_script( 'coming-soon-newsletter-mailpoet', '' );
-		wp_enqueue_script( 'coming-soon-newsletter-mailpoet' );
-		wp_add_inline_script( 'coming-soon-newsletter-mailpoet', 'var comingSoonNewsletter = ' . wp_json_encode( $mailpoet, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';' );
-	}
 }