Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer
Content_Renderer::find_post_content_width
Recursively find the post-content block's width in preprocessed blocks.
Method of the class: Content_Renderer{}
Hooks from the method
Returns
String|null. The post-content block's width or null if not found.
Usage
// private - for code of main (parent) class only $result = $this->find_post_content_width( $blocks, ?array $post_content_block_names ): ?string;
- $blocks(array) (required)
- Preprocessed blocks.
- ?array $post_content_block_names
- .
Default:null
Content_Renderer::find_post_content_width() Content Renderer::find post content width code WC 10.7.0
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;
}