tribe_all_occurrences_link( int $post_id = null, boolean $echo = true )
Recurring Event List Link
Contents
Display link for all occurrences of an event (based on the currently queried event).
Parameters
- $post_id
-
(int) (Optional) (optional) Which post we are looking for the All link.
Default value: null
- $echo
-
(boolean) (Optional) (optional) Should be echoed along side returning the value.
Default value: true
Return
(string) Link reference to all events in a recurrent event.
Source
File: src/functions/template-tags/general.php
function tribe_all_occurrences_link( $post_id = null, $echo = true ) { $cache_key_links = __FUNCTION__ . ':links'; $cache_key_parent_ids = __FUNCTION__ . ':parent_ids'; $cache_links = tribe_get_var( $cache_key_links, [] ); $cache_parent_ids = tribe_get_var( $cache_key_parent_ids, [] ); $post_id = TEC::postIdHelper( $post_id ); if ( ! isset( $cache_parent_ids[ $post_id ] ) ) { $cache_parent_ids[ $post_id ] = wp_get_post_parent_id( $post_id ); tribe_set_var( $cache_key_parent_ids, $cache_parent_ids ); } // The ID to cache will be diff depending on Parent or child post of recurrent event. $cache_id = $cache_parent_ids[ $post_id ] ? $cache_parent_ids[ $post_id ] : $post_id; if ( ! isset( $cache_links[ $cache_id ] ) ) { $tribe_ecp = TEC::instance(); /** * Filters the "all occurrences" link. * @since 6.0.7 * @deprecated 6.0.7 To correct misspelling. * * @param string $link The link HTML string. */ $cache_links[ $cache_id ] = apply_filters_deprecated( 'tribe_all_occurences_link', [ $tribe_ecp->getLink( 'all', $post_id ) ], '6.0.7', 'tribe_all_occurrences_link', 'Filter deprecated to correct misspelling.' ); /** * Filters the "all occurrences" link. * @since 6.0.7 * * @param string $link The link HTML string. */ $cache_links[ $cache_id ] = apply_filters( 'tribe_all_occurrences_link', $tribe_ecp->getLink( 'all', $post_id ) ); tribe_set_var( $cache_key_links, $cache_links ); } if ( $echo ) { echo $cache_links[ $cache_id ]; } return $cache_links[ $cache_id ]; }
Changelog
Version | Description |
---|---|
5.0.0 | Introduced caching based on Post ID or Parent Post ID. |
3.0.0 | Introduced. |