WooCommerce Code Reference

Border_Style_Postprocessor
in package
implements Postprocessor

Postprocessor that handles border-style declarations to ensure consistent rendering across email clients.

This postprocessor addresses two main issues:

  1. Normalize border-style declarations: When using a uniform border-style declaration with non-uniform border-widths, some email clients (like Outlook) will incorrectly display borders on all sides even when the width is 0. For example: border-color: #000000; border-style: solid; border-width: 0 1px 0 0; would render borders on all sides in Outlook. This postprocessor normalizes the border-style declarations to only set styles for sides where border-width > 0: border-color: currentColor; border-width: 0 1px 0 0; border-right-style: solid;

  2. Add fallback border styles: The block editor provides a default solid style for borders that have a width but no style specified. This postprocessor adds the same border-style: solid fallback to ensure the email rendering matches what users see in the editor.

The postprocessor handles all border cases including:

  • Shorthand border declarations (border: 1px solid black)
  • Individual side declarations (border-top, border-right, etc.)
  • Individual property declarations (border-width, border-style, etc.)
  • Mixed combinations of the above

Interfaces, Classes and Traits

Postprocessor
Interface for postprocessors.

Table of Contents

postprocess()  : string
Postprocess the HTML.
expand_shorthand_value()  : array<string, string>
Expands shorthand border width and style values into individual properties.
extract_style_from_shorthand_value()  : string|null
Extracts the style from a shorthand value.
extract_width_from_shorthand_value()  : string|null
Extracts the width from a shorthand value.
is_nonzero_width()  : bool
Checks if a border width is nonzero.
process_style()  : string
Processes a style string to ensure border-style is set for borders with width > 0 and removes extra border-style properties.

Methods