Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors
Quote_Preprocessor::apply_typography_to_children
Apply typography styles to immediate paragraph children
Метод класса: Quote_Preprocessor{}
Хуков нет.
Возвращает
Массив. The processed blocks.
Использование
// private - только в коде основоного (родительского) класса $result = $this->apply_typography_to_children( $blocks, $quote_typography, $styles ): array;
- $blocks(массив) (обязательный)
- The blocks to process.
- $quote_typography(массив) (обязательный)
- The typography styles from the quote block.
- $styles(массив) (обязательный)
- The styles from the theme.
Код Quote_Preprocessor::apply_typography_to_children() Quote Preprocessor::apply typography to children WC 10.5.2
private function apply_typography_to_children( array $blocks, array $quote_typography, array $styles ): array {
$default_typography = $styles['blocks']['core/quote']['typography'] ?? array();
$merged_typography = array_merge( $default_typography, $quote_typography );
if ( empty( $merged_typography ) ) {
return $blocks;
}
foreach ( $blocks as &$block ) {
if ( 'core/paragraph' === $block['blockName'] ) {
if ( ! isset( $block['attrs'] ) ) {
$block['attrs'] = array();
}
if ( ! isset( $block['attrs']['style'] ) ) {
$block['attrs']['style'] = array();
}
if ( ! isset( $block['attrs']['style']['typography'] ) ) {
$block['attrs']['style']['typography'] = array();
}
// Merge typography styles, with block's own styles taking precedence.
$block['attrs']['style']['typography'] = array_merge(
$merged_typography,
$block['attrs']['style']['typography']
);
}
}
return $blocks;
}