Automattic\WooCommerce\Internal\StockNotifications\Emails

EmailManager::add_stylesheetspublicWC 1.0

Prints CSS in the emails.

Method of the class: EmailManager{}

Returns

String.

Usage

$EmailManager = new EmailManager();
$EmailManager->add_stylesheets( $css, $email );
$css(string) (required)
The CSS to print.
$email(WC_Email)
(Optional) The email object.
Default: null

EmailManager::add_stylesheets() code WC 10.3.6

<?php
public function add_stylesheets( $css, $email = null ) {

	/**
	 * `woocommerce_email_stock_notification_emails_to_style` filter.
	 *
	 * @since  10.2.0
	 *
	 * @return array
	 */
	if ( ( is_null( $email ) || ! in_array( $email->id, (array) apply_filters( 'woocommerce_email_stock_notification_emails_to_style', self::$email_ids ), true ) ) ) {
		return $css;
	}

	// General text.
	$text = get_option( 'woocommerce_email_text_color' );

	// Primary color.
	$base = get_option( 'woocommerce_email_base_color' );

	/**
	 * `woocommerce_email_stock_notification_base_text_color` filter.
	 *
	 * @since  10.2.0
	 *
	 * @return string
	 */
	$base_text = (string) apply_filters( 'woocommerce_email_stock_notification_base_text_color', wc_light_or_dark( $base, '#202020', '#ffffff' ), $email );

	ob_start();
	?>
	#header_wrapper h1 {
		line-height: 1em !important;
	}
	#notification__container {
		color: <?php echo esc_attr( $text ); ?> !important;
		padding: 20px 20px;
		text-align: center;
		font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
		width: 100%;
	}
	#notification__into_content {
		margin-bottom: 48px;
		color: <?php echo esc_attr( $text ); ?> !important;
	}
	#notification__product__image {
		text-align: center;
		margin-bottom: 20px;
		width: 100%;
	}
	#notification__product__image img {
		margin-right: 0;
		width: 220px;
	}
	#notification__product__title {
		font-size: 16px;
		font-weight: bold;
		line-height: 130%;
		margin-bottom: 5px;
		color: <?php echo esc_attr( $text ); ?> !important;
	}
	#notification__product__attributes table {
		width: 100%;
		padding: 0;
		margin: 0;
		color: <?php echo esc_attr( $text ); ?> !important;
	}
	#notification__product__attributes th,
	#notification__product__attributes td {
		color: <?php echo esc_attr( $text ); ?> !important;
		padding: 4px !important;
		text-align: center;
	}
	#notification__product__price {
		margin-bottom: 20px;
		color: <?php echo esc_attr( $text ); ?> !important;
	}
	#notification__action_button {
		text-decoration: none;
		display: inline-block;
		background: <?php echo esc_attr( $base ); ?>;
		color: <?php echo esc_attr( $base_text ); ?> !important;
		border: 10px solid <?php echo esc_attr( $base ); ?>;
	}
	#notification__verification_expiration {
		font-size: 0.8em;
		margin-top: 20px;
		color: <?php echo esc_attr( $text ); ?>;
	}
	#notification__footer {
		text-align: center;
		margin-top: 20px;
		color: <?php echo esc_attr( $text ); ?>;
	}
	#notification__unsubscribe_link {
		color: <?php echo esc_attr( $text ); ?>;
	}
	#notification__product__price .screen-reader-text {
		display: none;
	}
	<?php
	$css .= ob_get_clean();

	return $css;
}