Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Post_Template::find_link_href
Return the href of the nearest ancestor <a> of the given image, or an empty string.
Метод класса: Post_Template{}
Хуков нет.
Возвращает
string.
Использование
// private - только в коде основоного (родительского) класса $result = $this->find_link_href( $img_element ): string;
- $img_element(DOMElement) (обязательный)
- The image element.
Код Post_Template::find_link_href() Post Template::find link href WC 11.1.1
private function find_link_href( \DOMElement $img_element ): string {
$parent = $img_element->parentNode; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
while ( $parent instanceof \DOMElement ) {
if ( 'a' === $parent->tagName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
return $parent->getAttribute( 'href' );
}
$parent = $parent->parentNode; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
}
return '';
}