Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer
Content_Renderer::find_post_content_width
Recursively find the post-content block's width in preprocessed blocks.
Метод класса: Content_Renderer{}
Хуки из метода
Возвращает
Строку|null. The post-content block's width or null if not found.
Использование
// private - только в коде основоного (родительского) класса $result = $this->find_post_content_width( $blocks, ?array $post_content_block_names ): ?string;
- $blocks(массив) (обязательный)
- Preprocessed blocks.
- ?array $post_content_block_names
- .
По умолчанию:null
Код Content_Renderer::find_post_content_width() Content Renderer::find post content width WC 10.8.1
private function find_post_content_width( array $blocks, ?array $post_content_block_names = null ): ?string {
if ( null === $post_content_block_names ) {
$post_content_block_names = (array) apply_filters(
'woocommerce_email_editor_post_content_block_names',
array( 'core/post-content' )
);
}
foreach ( $blocks as $block ) {
$block_name = $block['blockName'] ?? '';
if ( in_array( $block_name, $post_content_block_names, true ) ) {
return $block['email_attrs']['width'] ?? null;
}
if ( ! empty( $block['innerBlocks'] ) ) {
$found = $this->find_post_content_width( $block['innerBlocks'], $post_content_block_names );
if ( null !== $found ) {
return $found;
}
}
}
return null;
}