tribe_get_venue_website_link( ?int $post_id = null, ?string $label = null, string $target = '_self' )
Get the link for the venue website.
Contents
Parameters
- $post_id
-
(?int) (Optional) The event or venue ID.
Default value: null
- $label
-
(?string) (Optional) The label for the link.
Default value: null
- $target
-
(string) (Optional) The target attribute for the link.
Default value: '_self'
Return
(string) Formatted link to the venue website
Source
File: src/functions/template-tags/venue.php
function tribe_get_venue_website_link( $post_id = null, $label = null ) {
$url = tribe_get_venue_website_url( $post_id );
if ( ! empty( $url ) ) {
$label = is_null( $label ) ? $url : $label;
if ( ! empty( $url ) ) {
$parseUrl = parse_url( $url );
if ( empty( $parseUrl['scheme'] ) ) {
$url = "http://$url";
}
}
/**
* Allows customization of a venue's website link target.
*
* @since ??
* @since 4.5.11 Added docblock and venue ID to filter.
*
* @param string $output The venue's website link target.
* @param int $post_id The venue ID.
*/
$website_link_target = apply_filters( 'tribe_get_venue_website_link_target', '_self', $post_id );
/**
* Allows customization of a venue's website link label.
*
* @since ??
* @since 4.5.11 Added docblock and venue ID to filter.
*
* @param string $label The venue's website link label.
* @param int $post_id The venue ID.
*/
$website_link_label = apply_filters( 'tribe_get_venue_website_link_label', esc_html( $label ), $post_id );
$html = sprintf(
'<a href="%s" target="%s">%s</a>',
esc_attr( esc_url( $url ) ),
$website_link_target,
$website_link_label
);
} else {
$html = '';
}
/**
* Allows customization of a venue's website link.
*
* @since ??
* @since 4.5.11 Added docblock.
*
* @param string $html The assembled HTML link tag of venue's website link.
* @param int $post_id The venue ID.
*/
return apply_filters( 'tribe_get_venue_website_link', $html, $post_id );
}
Changelog
| Version | Description |
|---|---|
| 3.0 | Introduced. |