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

Image::remove_style_attribute_from_elementprivateWC 1.0

Remove style attribute from the element.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->remove_style_attribute_from_element( $block_content, $tag, $style_name ): string;
$block_content(строка) (обязательный)
Block content.
$tag(массив) (обязательный)
.
$style_name(строка) (обязательный)
Name of the style to remove.

Код Image::remove_style_attribute_from_element() WC 10.0.2

private function remove_style_attribute_from_element( $block_content, array $tag, string $style_name ): string {
	$html = new \WP_HTML_Tag_Processor( $block_content );
	if ( $html->next_tag( $tag ) ) {
		/** @var string $element_style */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort -- used for phpstan
		$element_style = $html->get_attribute( 'style' ) ?? '';
		$element_style = preg_replace( '/' . $style_name . ':(.?[0-9]+px)+;?/', '', $element_style );
		$html->set_attribute( 'style', esc_attr( strval( $element_style ) ) );
		$block_content = $html->get_updated_html();
	}

	return $block_content;
}