Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Abstract_Block_Renderer::get_inner_content
Extract inner content from a wrapper element.
Removes the outer wrapper element (e.g., div) and returns only the inner HTML content. This is useful when you need to strip the wrapper and use only the inner content.
Method of the class: Abstract_Block_Renderer{}
No Hooks.
Returns
String. Inner content without the wrapper element, or original content if wrapper not found.
Usage
// protected - for code of main (parent) or child class $result = $this->get_inner_content( $block_content, $tag_name ): string;
- $block_content(string) (required)
- Block content with wrapper element.
- $tag_name(string)
- Tag name of the wrapper element .
Default:'div'
Abstract_Block_Renderer::get_inner_content() Abstract Block Renderer::get inner content code WC 10.8.1
protected function get_inner_content( string $block_content, string $tag_name = 'div' ): string {
$dom_helper = new Dom_Document_Helper( $block_content );
$element = $dom_helper->find_element( $tag_name );
return $element ? $dom_helper->get_element_inner_html( $element ) : $block_content;
}