Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Gallery::extract_gallery_caption
Extract gallery-level caption from the original block content.
Метод класса: Gallery{}
Хуков нет.
Возвращает
Строку. Gallery caption or empty string if not found.
Использование
// private - только в коде основоного (родительского) класса $result = $this->extract_gallery_caption( $block_content ): string;
- $block_content(строка) (обязательный)
- Original block content.
Код Gallery::extract_gallery_caption() Gallery::extract gallery caption WC 10.4.3
private function extract_gallery_caption( string $block_content ): string {
// Look for gallery-level caption: <figcaption class="blocks-gallery-caption wp-element-caption">.
// Enhanced security: validate container attributes before extracting content.
if ( preg_match( '/(<figcaption class="blocks-gallery-caption[^"]*"[^>]*>)(.*?)(<\/figcaption>)/s', $block_content, $matches ) ) {
// Validate the figcaption container attributes for security.
if ( Html_Processing_Helper::validate_container_attributes( $matches[1] . $matches[3] ) ) {
return Html_Processing_Helper::sanitize_caption_html( trim( $matches[2] ) );
}
}
return '';
}