EmailImprovements.php
| 1 | <?php |
| 2 | /** |
| 3 | * Adds a note when the email improvements feature is enabled for existing stores |
| 4 | * or when the feature is not enabled to try the new templates. |
| 5 | * |
| 6 | * @since 9.9.0 |
| 7 | */ |
| 8 | |
| 9 | declare( strict_types=1 ); |
| 10 | |
| 11 | namespace Automattic\WooCommerce\Internal\Admin\Notes; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | use Automattic\WooCommerce\Admin\Notes\Note; |
| 16 | use Automattic\WooCommerce\Admin\Notes\NoteTraits; |
| 17 | use Automattic\WooCommerce\Internal\Admin\EmailImprovements\EmailImprovements as EmailImprovementsFeature; |
| 18 | /** |
| 19 | * EmailImprovements |
| 20 | */ |
| 21 | class EmailImprovements { |
| 22 | use NoteTraits; |
| 23 | |
| 24 | /** |
| 25 | * Name of the note for use in the database. |
| 26 | */ |
| 27 | const NOTE_NAME = 'wc-admin-email-improvements'; |
| 28 | |
| 29 | /** |
| 30 | * Get the note. |
| 31 | * |
| 32 | * @return Note|void |
| 33 | */ |
| 34 | public static function get_note() { |
| 35 | if ( EmailImprovementsFeature::is_email_improvements_enabled_for_existing_stores() ) { |
| 36 | return self::get_email_improvements_enabled_note(); |
| 37 | } |
| 38 | |
| 39 | if ( EmailImprovementsFeature::should_notify_merchant_about_email_improvements() ) { |
| 40 | return self::get_try_email_improvements_note(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Get the note for when the email improvements feature is enabled for existing stores. |
| 46 | * |
| 47 | * @return Note |
| 48 | */ |
| 49 | private static function get_email_improvements_enabled_note() { |
| 50 | $note = new Note(); |
| 51 | $note->set_title( __( 'Your store emails have had an upgrade!', 'woocommerce' ) ); |
| 52 | $note->set_content( __( 'We’ve made some exciting improvements to your email templates, including modern, shopper-friendly designs and new customization options. And if you’re using a block theme, you can automatically sync your theme styles! Head to your email settings to explore the new changes.', 'woocommerce' ) ); |
| 53 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 54 | $note->set_name( self::NOTE_NAME ); |
| 55 | $note->set_source( 'woocommerce-admin' ); |
| 56 | $note->add_action( |
| 57 | 'customize-your-emails', |
| 58 | __( 'Customize your emails', 'woocommerce' ), |
| 59 | '?page=wc-settings&tab=email' |
| 60 | ); |
| 61 | return $note; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get the note for when the email improvements feature is disabled. |
| 66 | * |
| 67 | * @return Note |
| 68 | */ |
| 69 | private static function get_try_email_improvements_note() { |
| 70 | $note = new Note(); |
| 71 | $note->set_title( __( 'Store emails have had an upgrade!', 'woocommerce' ) ); |
| 72 | $note->set_content( __( 'We’ve made some exciting improvements to our email templates, including modern, shopper-friendly designs and new customization options. And if you’re using a block theme, you can automatically sync your theme styles! Head to your email settings to explore the new features.', 'woocommerce' ) ); |
| 73 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 74 | $note->set_name( self::NOTE_NAME ); |
| 75 | $note->set_source( 'woocommerce-admin' ); |
| 76 | $note->add_action( |
| 77 | 'try-the-new-templates', |
| 78 | __( 'Try the new templates', 'woocommerce' ), |
| 79 | '?page=wc-settings&tab=email&try-new-templates' |
| 80 | ); |
| 81 | return $note; |
| 82 | } |
| 83 | } |
| 84 |