Commit c62433646e for woocommerce

commit c62433646e01cd3966293e4d2f2eddcfa250090b
Author: Seun Olorunsola <30554163+triple0t@users.noreply.github.com>
Date:   Tue Dec 16 16:31:45 2025 +0100

    Use store title as default email "From" name instead of hardcoded WordPress site name (#62369)

    * Add default fallback to blogname for get_from_name methods

    Update get_from_name methods in WC_Emails and WC_Email classes to ensure consistent behavior when the email name option is not set.

    Adjust TemplateApiController to reflect the new default behavior for sender settings.

    * Add 'skip_initial_save' option to settings and update installation logic

    When set to true, this allows the plugin to skip saving the initial option value in the db for the settings field.

    In this case, we don't want to save the initial value for the woocommerce_email_from_name field. This will allow us to continue using the blog title for the email “from” until the user manually updates it or saves the email settings field, which will repopulate the option.

    * Add changelog and fix lint warnings

    * Lint warning fixes

    * Remove strict type declarations from the email settings class for backwards compatibility purposes.

    * Remove deprecated PHPDoc parse error entries from WooCommerce PHPStan baseline file to streamline linting process.

diff --git a/packages/js/settings-editor/typings/global.d.ts b/packages/js/settings-editor/typings/global.d.ts
index a9638ec770..437c6aa863 100644
--- a/packages/js/settings-editor/typings/global.d.ts
+++ b/packages/js/settings-editor/typings/global.d.ts
@@ -30,6 +30,7 @@ declare global {
 		desc?: string;
 		description?: string;
 		desc_tip?: boolean | string;
+		skip_initial_save?: boolean;
 		default?: string | number | boolean | object;
 		value: string | number | boolean | object;
 		placeholder?: string;
diff --git a/plugins/woocommerce/changelog/stomail-7654-email-from-name-defaults-to-my-wordpress-site-instead-of b/plugins/woocommerce/changelog/stomail-7654-email-from-name-defaults-to-my-wordpress-site-instead-of
new file mode 100644
index 0000000000..f8e0b477a4
--- /dev/null
+++ b/plugins/woocommerce/changelog/stomail-7654-email-from-name-defaults-to-my-wordpress-site-instead-of
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+Allow “Email FROM” to automatically use the “Store Title” as the value unless the merchant manually changes it.
diff --git a/plugins/woocommerce/includes/admin/settings/class-wc-settings-emails.php b/plugins/woocommerce/includes/admin/settings/class-wc-settings-emails.php
index 5eceab2508..493b9d2c68 100644
--- a/plugins/woocommerce/includes/admin/settings/class-wc-settings-emails.php
+++ b/plugins/woocommerce/includes/admin/settings/class-wc-settings-emails.php
@@ -123,14 +123,15 @@ class WC_Settings_Emails extends WC_Settings_Page {
 				),

 				array(
-					'title'    => __( '"From" name', 'woocommerce' ),
-					'desc'     => '',
-					'id'       => 'woocommerce_email_from_name',
-					'type'     => 'text',
-					'css'      => 'min-width:400px;',
-					'default'  => esc_attr( get_bloginfo( 'name', 'display' ) ),
-					'autoload' => false,
-					'desc_tip' => true,
+					'title'             => __( '"From" name', 'woocommerce' ),
+					'desc'              => '',
+					'id'                => 'woocommerce_email_from_name',
+					'type'              => 'text',
+					'css'               => 'min-width:400px;',
+					'default'           => esc_attr( get_bloginfo( 'name', 'display' ) ),
+					'autoload'          => false,
+					'desc_tip'          => true,
+					'skip_initial_save' => true,
 				),

 				array(
@@ -371,6 +372,13 @@ class WC_Settings_Emails extends WC_Settings_Page {
 		// Remove empty elements that depend on the email_improvements feature flag.
 		$settings = array_filter( $settings );

+		/**
+		 * Filters the email settings array.
+		 *
+		 * @since 2.1.0
+		 *
+		 * @param array $settings Array of email settings.
+		 */
 		return apply_filters( 'woocommerce_email_settings', $settings );
 	}

@@ -466,6 +474,13 @@ class WC_Settings_Emails extends WC_Settings_Page {
 				<thead>
 					<tr>
 						<?php
+						/**
+						 * Filters the columns displayed in the email settings table.
+						 *
+						 * @since 2.1.0
+						 *
+						 * @param array $columns Array of column keys and labels.
+						 */
 						$columns = apply_filters(
 							'woocommerce_email_setting_columns',
 							array(
@@ -548,6 +563,13 @@ class WC_Settings_Emails extends WC_Settings_Page {
 										</td>';
 										break;
 									default:
+										/**
+										 * Fires when rendering a custom column in the email settings table.
+										 *
+										 * @since 2.1.0
+										 *
+										 * @param WC_Email $email The email object.
+										 */
 										do_action( 'woocommerce_email_setting_column_' . $key, $email );
 										break;
 								}
diff --git a/plugins/woocommerce/includes/class-wc-emails.php b/plugins/woocommerce/includes/class-wc-emails.php
index b0f6e58cf4..4f137a43c3 100644
--- a/plugins/woocommerce/includes/class-wc-emails.php
+++ b/plugins/woocommerce/includes/class-wc-emails.php
@@ -309,7 +309,7 @@ class WC_Emails {
 	/**
 	 * Return the email classes - used in admin to load settings.
 	 *
-	 * @return WC_Email[]
+	 * @return array<string, WC_Email> Email classes.
 	 */
 	public function get_emails() {
 		return $this->emails;
@@ -321,7 +321,8 @@ class WC_Emails {
 	 * @return string
 	 */
 	public function get_from_name() {
-		return wp_specialchars_decode( get_option( 'woocommerce_email_from_name' ), ENT_QUOTES );
+		$default = get_bloginfo( 'name', 'display' );
+		return wp_specialchars_decode( get_option( 'woocommerce_email_from_name', $default ), ENT_QUOTES );
 	}

 	/**
diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php
index a2ac1e4946..c9b41c552f 100644
--- a/plugins/woocommerce/includes/class-wc-install.php
+++ b/plugins/woocommerce/includes/class-wc-install.php
@@ -1109,8 +1109,11 @@ class WC_Install {
 			foreach ( $subsections as $subsection ) {
 				foreach ( $section->get_settings( $subsection ) as $value ) {
 					if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
-						$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
-						add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
+						$autoload          = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
+						$skip_initial_save = isset( $value['skip_initial_save'] ) ? (bool) $value['skip_initial_save'] : false;
+						if ( ! $skip_initial_save ) {
+							add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
+						}
 					}
 				}
 			}
diff --git a/plugins/woocommerce/includes/emails/class-wc-email.php b/plugins/woocommerce/includes/emails/class-wc-email.php
index 7a93bab08c..6135008f47 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email.php
@@ -414,7 +414,7 @@ class WC_Email extends WC_Settings_API {
 		 * @since 6.8.0
 		 *
 		 * @param bool $default_value The default returned value.
-		 * @param WC_Email $this The WC_Email object.
+		 * @param WC_Email $email The WC_Email object.
 		 */
 		$switch_email_locale = apply_filters( 'woocommerce_allow_switching_email_locale', true, $this );

@@ -434,7 +434,7 @@ class WC_Email extends WC_Settings_API {
 		 * @since 6.8.0
 		 *
 		 * @param bool $default_value The default returned value.
-		 * @param WC_Email $this The WC_Email object.
+		 * @param WC_Email $email The WC_Email object.
 		 */
 		$restore_email_locale = apply_filters( 'woocommerce_allow_restoring_email_locale', true, $this );

@@ -888,7 +888,7 @@ class WC_Email extends WC_Settings_API {
 			 *
 			 * @param callable $style_inline_callback The default email inline styling callback.
 			 * @param string|null $content Content that will receive inline styles.
-			 * @param WC_Email $this The WC_Email object.
+			 * @param WC_Email $email The WC_Email object.
 			 */
 			$style_inline_callback = apply_filters( 'woocommerce_mail_style_inline_callback', array( $this, 'apply_inline_style' ), $content, $this );

@@ -941,7 +941,7 @@ class WC_Email extends WC_Settings_API {
 				 * @since 4.1.0
 				 *
 				 * @param CssInliner $css_inliner CssInliner instance.
-				 * @param WC_Email $this WC_Email instance.
+				 * @param WC_Email $email WC_Email instance.
 				 */
 				do_action( 'woocommerce_emogrifier', $css_inliner, $this );

@@ -1025,7 +1025,17 @@ class WC_Email extends WC_Settings_API {
 	 * @return string
 	 */
 	public function get_from_name( $from_name = '' ) {
-		$from_name = apply_filters( 'woocommerce_email_from_name', get_option( 'woocommerce_email_from_name' ), $this, $from_name );
+		$default = get_bloginfo( 'name', 'display' );
+		/**
+		 * Filters the "from" name for outgoing emails.
+		 *
+		 * @since 2.1.0
+		 *
+		 * @param string|mixed $from_name        The from name.
+		 * @param WC_Email     $email            Email object.
+		 * @param string       $default_from_name Default from name.
+		 */
+		$from_name = apply_filters( 'woocommerce_email_from_name', get_option( 'woocommerce_email_from_name', $default ), $this, $from_name );
 		return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
 	}

@@ -1138,7 +1148,7 @@ class WC_Email extends WC_Settings_API {
 		 * @since 5.6.0
 		 * @param bool     $return Whether the email was sent successfully.
 		 * @param string   $id     Email ID.
-		 * @param WC_Email $this   WC_Email instance.
+		 * @param WC_Email $email  WC_Email instance.
 		 */
 		do_action( 'woocommerce_email_sent', $return, (string) $this->id, $this );

diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 434f762e83..74491a8d9f 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -23946,12 +23946,6 @@ parameters:
 			count: 4
 			path: includes/emails/class-wc-email.php

-		-
-			message: '#^@param tag must not be named \$this\. Choose a descriptive alias, for example \$instance\.$#'
-			identifier: phpDoc.parseError
-			count: 5
-			path: includes/emails/class-wc-email.php
-
 		-
 			message: '#^Access to property \$AltBody on an unknown class PHPMailer\.$#'
 			identifier: class.notFound
@@ -24078,24 +24072,6 @@ parameters:
 			count: 1
 			path: includes/emails/class-wc-email.php

-		-
-			message: '#^PHPDoc tag @param has invalid value \(WC_Email \$this The WC_Email object\.\)\: Unexpected token "\$this", expected variable at offset 161 on line 7$#'
-			identifier: phpDoc.parseError
-			count: 1
-			path: includes/emails/class-wc-email.php
-
-		-
-			message: '#^PHPDoc tag @param has invalid value \(WC_Email \$this The WC_Email object\.\)\: Unexpected token "\$this", expected variable at offset 162 on line 7$#'
-			identifier: phpDoc.parseError
-			count: 1
-			path: includes/emails/class-wc-email.php
-
-		-
-			message: '#^PHPDoc tag @param has invalid value \(WC_Email \$this The WC_Email object\.\)\: Unexpected token "\$this", expected variable at offset 300 on line 8$#'
-			identifier: phpDoc.parseError
-			count: 1
-			path: includes/emails/class-wc-email.php
-
 		-
 			message: '#^Parameter \#1 \$nonce of function wp_verify_nonce expects string, array\|string given\.$#'
 			identifier: argument.type
diff --git a/plugins/woocommerce/src/Internal/EmailEditor/EmailTemplates/TemplateApiController.php b/plugins/woocommerce/src/Internal/EmailEditor/EmailTemplates/TemplateApiController.php
index 46ee451efb..51057c0e42 100644
--- a/plugins/woocommerce/src/Internal/EmailEditor/EmailTemplates/TemplateApiController.php
+++ b/plugins/woocommerce/src/Internal/EmailEditor/EmailTemplates/TemplateApiController.php
@@ -28,7 +28,7 @@ class TemplateApiController {

 		return array(
 			'sender_settings' => array(
-				'from_name'    => get_option( 'woocommerce_email_from_name' ),
+				'from_name'    => get_option( 'woocommerce_email_from_name', get_bloginfo( 'name', 'display' ) ),
 				'from_address' => get_option( 'woocommerce_email_from_address' ),
 			),
 		);