Automattic\WooCommerce\Internal\EmailEditor
WooContentProcessor::prepare_css
Filter CSS for the email. The CSS from the email editor was already inlined. The method hooks to woocommerce_email_styles and removes CSS rules that we don't want to apply to the email.
Typography properties (font-size, font-weight, line-height, letter-spacing) are stripped because the email editor theme controls all typography via theme.json. Leaving these in the WooCommerce CSS would override the editor's heading sizes and weights.
Method of the class: WooContentProcessor{}
No Hooks.
Returns
String.
Usage
$WooContentProcessor = new WooContentProcessor(); $WooContentProcessor->prepare_css( $css ): string;
- $css(string) (required)
- CSS.
Changelog
| Since 10.8.0 | Introduced. |
WooContentProcessor::prepare_css() WooContentProcessor::prepare css code WC 10.9.1
public function prepare_css( string $css ): string {
remove_filter( 'woocommerce_email_styles', array( $this, 'prepare_css' ) );
// Remove typography declarations from WooCommerce CSS.
// The email editor theme.json controls all typography; WC CSS would override it.
return (string) preg_replace(
array(
'/color\s*:\s*[^;]+;/',
'/font-family\s*:\s*[^;]+;/',
'/font-size\s*:\s*[^;]+;/',
'/font-weight\s*:\s*[^;]+;/',
'/line-height\s*:\s*[^;]+;/',
'/letter-spacing\s*:\s*[^;]+;/',
),
'',
$css
);
}