Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Embed::render_caption │ private │ WC 1.0

Render the block's figcaption (if any) as a centered block appended below the embed output.

Метод класса: Embed{}

Хуков нет.

Возвращает

string. Caption HTML or empty string.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->render_caption( $block_content ): string;
$block_content(строка) (обязательный)
Block content.

Код Embed::render_caption() WC 11.2.2

private function render_caption( string $block_content ): string {
	if ( ! preg_match( '/<figcaption[^>]*>(.*?)<\/figcaption>/is', $block_content, $matches ) ) {
		return '';
	}

	$caption = trim( $matches[1] );
	if ( '' === $caption ) {
		return '';
	}

	return '<div style="text-align: center; margin-top: 8px;">' . Html_Processing_Helper::sanitize_caption_html( $caption ) . '</div>';
}