View::get_link_label( string $url )
Builds the link label to use from the URL.
Contents
This is usually used to build the next and prev link URLs labels. Extending classes can customize the format of the the label by overriding the get_label_format method.
See also
- View::get_label_format(),: the method child classes should override to customize the link label format.
Parameters
- $url
-
(string) (Required) The input URL to build the link label from.
Return
(string) The formatted and localized, but not HTML escaped, link label.
Source
File: src/Tribe/Views/V2/View.php
public function get_link_label( $url ) {
if ( empty( $url ) ) {
return '';
}
$url_query = parse_url( $url, PHP_URL_QUERY );
if ( empty( $url_query ) ) {
return '';
}
parse_str( $url_query, $args );
$date = Arr::get_first_set( $args, [ 'eventDate', 'tribe-bar-date' ], false );
if ( false === $date ) {
return '';
}
$date_object = Dates::build_date_object( $date );
$format = $this->get_label_format();
/**
* Filters the `date` format that will be used to produce a View link label.
*
* @since 4.9.9
*
* @param string $format The label format the View will use to product a View link label; e.g. the
* previous and next links.
* @param \DateTime $date The date object that is being used to build the label.
* @param View $view This View instance.
*/
$format = apply_filters( "tribe_events_views_v2_{$this->slug}_link_label_format", $format, $this, $date );
return date_i18n( $format, $date_object->getTimestamp() + $date_object->getOffset() );
}
Changelog
| Version | Description |
|---|---|
| 4.9.9 | Introduced. |