Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors

Spacing_Preprocessor::get_columns_block_gapprivateWC 1.0

Extracts the horizontal blockGap from a columns block.

Only an explicitly defined horizontal gap (blockGap.left) is honored; we do not fall back to the global block spacing, which is vertical-only in the editor and would otherwise add a gap that widens the rendered email.

Method of the class: Spacing_Preprocessor{}

No Hooks.

Returns

String|null. The horizontal gap value (e.g., "30px" or "var:preset|spacing|30") or null if not explicitly set.

Usage

// private - for code of main (parent) class only
$result = $this->get_columns_block_gap( $columns_block ): ?string;
$columns_block(array) (required)
The columns block.

Spacing_Preprocessor::get_columns_block_gap() code WC 11.0.1

private function get_columns_block_gap( array $columns_block ): ?string {
	$block_gap = $columns_block['attrs']['style']['spacing']['blockGap'] ?? null;

	// Columns block uses object format: { "top": "...", "left": "..." }.
	// Only apply a horizontal gap when blockGap.left is explicitly set.
	if ( is_array( $block_gap ) && isset( $block_gap['left'] ) && is_string( $block_gap['left'] ) ) {
		$gap_value = $block_gap['left'];

		// Validate against potentially malicious values.
		if ( preg_match( '/[<>"\']/', $gap_value ) ) {
			return null;
		}

		// Return the value as-is. WP's styles engine will handle transformation of preset variables.
		return $gap_value;
	}

	return null;
}