WC_Settings_Emails::email_improvements_buttonpublicWC 1.0

Show a button to revert or enable email improvements.

Method of the class: WC_Settings_Emails{}

No Hooks.

Returns

null. Nothing (null).

Usage

$WC_Settings_Emails = new WC_Settings_Emails();
$WC_Settings_Emails->email_improvements_button(): void;

WC_Settings_Emails::email_improvements_button() code WC 10.3.3

<?php
public function email_improvements_button(): void {
	if ( 'yes' === get_transient( 'wc_settings_email_improvements_reverted' ) ) {
		?>
		<div id="wc_settings_features_email_feedback_slotfill"></div>
		<?php
	}
	$is_feature_enabled   = FeaturesUtil::feature_is_enabled( 'email_improvements' );
	$trying_new_templates = $this->is_trying_new_templates();
	if ( ! $is_feature_enabled && ! $trying_new_templates ) {
		?>
		<hr class="wc-settings-email-color-palette-separator" />
		<a href="?page=wc-settings&tab=email&try-new-templates" class="components-button is-link">
			<?php esc_html_e( 'Try our new email templates!', 'woocommerce' ); ?>
		</a>
		<?php
		return;
	}

	$has_feature_enabled_since_installation = 'yes' === get_option( 'woocommerce_email_improvements_default_enabled', 'no' );
	if ( $is_feature_enabled && ! $has_feature_enabled_since_installation ) {
		$disable_feature_args = array(
			'email_improvements' => '0',
			'_feature_nonce'     => wp_create_nonce( 'change_feature_enable' ),
		);
		?>
		<hr class="wc-settings-email-color-palette-separator" />
		<a href="<?php echo esc_url( add_query_arg( $disable_feature_args ) ); ?>"
			class="components-button is-link"
			onclick="return confirm('<?php esc_attr_e( 'Are you sure want to revert to legacy? Doing so will erase any changes you’ve made to your new email templates, and will restore your previous email designs.', 'woocommerce' ); ?>');"
		>
			<?php esc_html_e( 'Revert to legacy template', 'woocommerce' ); ?>
		</a>
		<?php
		return;
	}
	?>
	<?php
}