WooCommerce Code Reference

Spacing_Preprocessor
in package
implements Preprocessor

This preprocessor is responsible for setting default spacing values for blocks.

In the early development phase, we are setting only margin-top for blocks that are not first or last in the columns block.

Interfaces, Classes and Traits

Preprocessor
Interface Preprocessor

Table of Contents

preprocess()  : array<string|int, mixed>
Preprocesses the parsed blocks.
add_block_gaps()  : array<string|int, mixed>
Adds margin-top to blocks that are not first or last in the columns block.
get_columns_block_gap()  : string|null
Extracts the horizontal blockGap from a columns block.

Methods

preprocess()

Preprocesses the parsed blocks.

public preprocess(array<string|int, mixed> $parsed_blocks, array<string|int, mixed> $layout, array<string|int, mixed> $styles) : array<string|int, mixed>
Parameters
$parsed_blocks : array<string|int, mixed>

Parsed blocks.

$layout : array<string|int, mixed>

Layout.

$styles : array<string|int, mixed>

Styles.

Return values
array<string|int, mixed>

add_block_gaps()

Adds margin-top to blocks that are not first or last in the columns block.

private add_block_gaps(array<string|int, mixed> $parsed_blocks[, string $gap = '' ][, array<string|int, mixed>|null $parent_block = null ]) : array<string|int, mixed>
Parameters
$parsed_blocks : array<string|int, mixed>

Parsed blocks.

$gap : string = ''

Gap.

$parent_block : array<string|int, mixed>|null = null

Parent block.

Return values
array<string|int, mixed>

get_columns_block_gap()

Extracts the horizontal blockGap from a columns block.

private get_columns_block_gap(array<string|int, mixed> $columns_block[, string $default_gap = '' ]) : string|null
Parameters
$columns_block : array<string|int, mixed>

The columns block.

$default_gap : string = ''

Default gap value to use if blockGap is not set on the columns block.

Return values
string|nullThe horizontal gap value (e.g., "30px" or "var:preset|spacing|30") or null if not set.