Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Media_Text::wrap_media_with_link
Wrap media content with a link if it's not already wrapped.
Method of the class: Media_Text{}
No Hooks.
Returns
String. Media content wrapped with link.
Usage
// private - for code of main (parent) class only $result = $this->wrap_media_with_link( $media_content, $href ): string;
- $media_content(string) (required)
- The media content (inner content from figure element).
- $href(string) (required)
- The URL to link to.
Media_Text::wrap_media_with_link() Media Text::wrap media with link code WC 10.5.0
private function wrap_media_with_link( string $media_content, string $href ): string {
// If media is already wrapped in a link, return as-is.
if ( false !== strpos( $media_content, '<a ' ) ) {
return $media_content;
}
// Wrap the media content with a link.
return '<a href="' . esc_url( $href ) . '">' . $media_content . '</a>';
}