8889841cPK qT[A day.phpnu [ \Tribe\Events\Views\V2\Views\Day_View::get_view_slug(),
'eventDate' => $date_obj->format( Tribe__Date_Utils::DBDATEFORMAT )
] );
/**
* Allows the filtering of a given day link to our views.
*
* @since ??
* @since 6.0.0 Uses Views V2 link structure.
*
* @param string $url Which URL we are using.
* @param string $date Which date was passed to build the URL.
*/
return (string) apply_filters( 'tribe_get_day_link', $url, $date );
}
}
PK qT[* * event.phpnu [ ID,
$cache_post->post_modified,
// Use the `post_password` field as we show/hide some information depending on that.
$cache_post->post_password,
// We must include options on cache key, because options influence the hydrated data on the Event object.
wp_json_encode( Tribe__Settings_Manager::get_options() ),
wp_json_encode( [
$cache['option_start_of_week'],
$cache['option_timezone_string'],
$cache['option_gmt_offset']
] ),
$output,
$filter,
];
$cache_key = 'tribe_get_event_' . md5( wp_json_encode( $key_fields ) );
// Try getting the memoized value.
$post = $cache->get( $cache_key, Tribe__Cache_Listener::TRIGGER_SAVE_POST );
if ( $post === false ) {
// No memoized value, build from properties.
$post = Event::from_post( $event )->to_post( OBJECT, $filter, $force );
/**
* Filters the event post object before caching it and returning it.
*
* Note: this value will be cached; as such this filter might not run on each request.
* If you need to filter the output value on each call of this function then use the `tribe_get_event_before`
* filter.
*
* @since 4.9.7
*
* @param WP_Post $post The event post object, decorated with a set of custom properties.
* @param string $output The output format to use.
* @param string $filter The filter, or context of the fetch.
*/
$post = apply_filters( 'tribe_get_event', $post, $output, $filter );
// Memoize the value.
$cache->set( $cache_key, $post, Tribe__Cache::NON_PERSISTENT, Tribe__Cache_Listener::TRIGGER_SAVE_POST );
}
if ( empty( $post ) ) {
return null;
}
/**
* Filters the event result after the event has been built from the function.
*
* Note: this value will not be cached and the caching of this value is a duty left to the filtering function.
*
* @since 5.0.0
*
* @param WP_Post $post The event post object to filter and return.
* @param int|WP_Post $event The event object to fetch.
* @param string|null $output The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
* correspond to a `WP_Post` object, an associative array, or a numeric array,
* respectively. Defaults to `OBJECT`.
* @param string $filter Type of filter to apply. Accepts 'raw', a valid date string or
* object to localize the event in a specific time-frame.
*/
$post = apply_filters( 'tribe_get_event_after', $post, $event, $output, $filter );
switch ( $output ) {
case ARRAY_A:
return (array) $post;
case ARRAY_N:
return array_values( (array) $post );
case OBJECT:
default;
return $post;
}
return $post;
}
}
PK qT[6F F general.phpnu [ https://evnt.is/v1-removal for template customization assistance.' );
}
if (
empty( $view )
&& (
is_singular( Tribe__Events__Main::POSTTYPE )
|| tribe_context()->is( 'event_post_type' )
)
) {
$view = 'single-event';
_deprecated_function( 'tribe_get_view( $view = false )', '6.0.0', 'of this method without a defined $view will be completely removed soon. Please refer to https://evnt.is/v1-removal for template customization' );
}
$template_file = Tribe__Events__Templates::getTemplateHierarchy( $view, [ 'disable_view_check' => true ] );
if ( file_exists( $template_file ) ) {
do_action( 'tribe_events_before_view', $template_file );
include( $template_file );
do_action( 'tribe_events_after_view', $template_file );
}
}
/**
* Get Event Label Singular.
* Returns the singular version of the Event Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 3.10
* @since 5.1.6 remove escaping.
*
* @return string The singular version of the Event Label.
*/
function tribe_get_event_label_singular() {
/**
* Allows customization of the singular version of the Event Label.
* Note: the output of this filter is not escaped!
*
* @since 3.10
* @since 5.1.6 Remove escaping.
*
* @param string $label The singular version of the Event label, defaults to "Event" (uppercase)
*/
return apply_filters(
'tribe_event_label_singular',
__( 'Event', 'the-events-calendar' )
);
}
/**
* Get Event Label Singular lowercase.
* Returns the lowercase singular version of the Event Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 4.1.1
* @since 5.1.6 remove escaping.
*
* @return string The lowercase singular version of the Event Label.
*/
function tribe_get_event_label_singular_lowercase() {
/**
* Allows customization of the singular lowercase version of the Event Label.
* Note: the output of this filter is not escaped!
*
* @since 4.1.1
* @since 5.1.6 Remove escaping.
*
* @param string $label The singular lowercase version of the Event label, defaults to "event" (lowercase)
*/
return apply_filters(
'tribe_event_label_singular_lowercase',
__( 'event', 'the-events-calendar' )
);
}
/**
* Get Event Label Plural.
* Returns the plural version of the Event Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 3.10
* @since 5.1.6 remove escaping.
*
* @return string The plural version of the Event Label.
*/
function tribe_get_event_label_plural() {
/**
* Allows customization of the plural version of the Event Label.
* Note: the output of this filter is not escaped!
*
* @since 3.10
* @since 5.1.6 Remove escaping.
*
* @param string $label The plural version of the Event label, defaults to "Events" (uppercase)
*/
return apply_filters(
'tribe_event_label_plural',
__( 'Events', 'the-events-calendar' )
);
}
/**
* Get Event Label Plural lowercase.
* Returns the plural version of the Event Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 4.1.1
* @since 5.1.6 remove escaping.
*
* @return string The lowercase plural version of the Event Label.
*/
function tribe_get_event_label_plural_lowercase() {
/**
* Allows customization of the plural lowercase version of the Event Label.
* Note: the output of this filter is not escaped!
*
* @since 4.1.1
* @since 5.1.6 Remove escaping.
*
* @param string $label The plural lowercase version of the Event label, defaults to "events" (lowercase)
*/
return apply_filters(
'tribe_event_label_plural_lowercase',
__( 'events', 'the-events-calendar' )
);
}
/**
* Get the filtered text label for the "Today" button on calendar views.
*
* @since 6.0.2
*
* @param \Tribe\Events\Views\V2\View_Interface $view The View currently rendering.
* Hint: In templates, you can call $this->get_view() to get the view.
*
* @return string The label for the "Today" button.
*/
function tec_events_get_today_button_label( $view = null ) {
$today = esc_html_x(
'Today',
'The default text label for the "today" button on main calendar views.',
'the-events-calendar'
);
/**
* Allows filtering of all labels for the today button at one time.
*
* @since 6.0.2
*
* @param string $today The string used for the "Today" button on calendar views.
* @param \Tribe\Events\Views\V2\View_Interface $view The View currently rendering.
*/
$today = apply_filters( 'tec_events_today_button_label', $today, $view );
// If we don't have the view - send it off!
if ( empty( $view ) ) {
return $today;
}
$view_slug = $view::get_view_slug();
/**
* Allows filtering a view-specific label for the today button.
*
* @since 6.0.2
*
* @param string $today The string used for the "Today" button on calendar views.
* @param \Tribe\Events\Views\V2\View_Interface $view The View currently rendering.
*/
return apply_filters( "tec_events_view_{$view_slug}_today_button_label", $today, $view );
}
/**
* Includes a template part, similar to the WP get template part, but looks
* in the correct directories for Tribe Events templates
*
* @uses Tribe__Templates::getTemplateHierarchy
*
* @param null|string $name
*
* @param array $data optional array of vars to inject into the template part
*
* @param string $slug
*/
function tribe_get_template_part( $slug, $name = null, array $data = null ) {
// Execute code for this part
do_action( 'tribe_pre_get_template_part_' . $slug, $slug, $name, $data );
// Setup possible parts
$templates = [];
if ( isset( $name ) ) {
$templates[] = $slug . '-' . $name . '.php';
}
$templates[] = $slug . '.php';
// Allow template parts to be filtered
$templates = apply_filters( 'tribe_get_template_part_templates', $templates, $slug, $name );
// Make any provided variables available in the template's symbol table
if ( is_array( $data ) ) {
extract( $data );
}
// loop through templates, return first one found.
foreach ( $templates as $template ) {
$file = Tribe__Events__Templates::getTemplateHierarchy( $template, [ 'disable_view_check' => true ] );
$file = apply_filters( 'tribe_get_template_part_path', $file, $template, $slug, $name );
$file = apply_filters( 'tribe_get_template_part_path_' . $template, $file, $slug, $name );
if ( file_exists( $file ) ) {
ob_start();
do_action( 'tribe_before_get_template_part', $template, $file, $template, $slug, $name );
include( $file );
do_action( 'tribe_after_get_template_part', $template, $file, $slug, $name );
$html = ob_get_clean();
echo apply_filters( 'tribe_get_template_part_content', $html, $template, $file, $slug, $name );
break; // We found our template, no need to continue the loop
}
}
do_action( 'tribe_post_get_template_part_' . $slug, $slug, $name, $data );
}
if ( ! function_exists( 'tribe_is_ajax_view_request' ) ) {
/**
* Check if the current request is for a tribe view via ajax
*
* @since 6.0.0 Refactored to use tribe_context().
*
* @param bool|string $view View slug.
*
* @return bool
* @category Events
*/
function tribe_is_ajax_view_request( $view = false ) {
$context = tribe_context();
$is_ajax_view_request = true;
if ( ! $context->doing_ajax() ) {
$is_ajax_view_request = false;
}
$view_slug = tribe_context()->get( 'view', null );
if ( empty( $view_slug ) ) {
$is_ajax_view_request = false;
} else {
if ( 'default' === $view_slug ) {
$view_slug = tribe( \Tribe\Events\Views\V2\Manager::class )->get_default_view_slug();
}
if ( $view !== $view_slug ) {
$is_ajax_view_request = false;
}
}
return apply_filters( 'tribe_is_ajax_view_request', $is_ajax_view_request, $view );
}
}
/**
* Event Type Test
*
* Checks type of $postId to determine if it is an Event
*
* @param int|WP_Post The event/post id or object. (optional)
*
* @return bool true if this post is an Event post type
* @category Events
*/
function tribe_is_event( $postId = null ) {
/**
* Filter: 'tribe_is_event'.
*
* @param bool $is_event
* @param int|WP_Post The event/post id or object. (optional)
*/
return apply_filters( 'tribe_is_event', Tribe__Events__Main::instance()->isEvent( $postId ), $postId );
}
/**
* Get Events from the database.
*
* Queries the events using the Query wrapper around the Events Repository.
*
* @link https://developer.wordpress.org/reference/classes/wp_query/
*
* @uses tribe_events()
* @uses Tribe__Events__Query::getEvents
*
* @param array $args {
* Optional. Array of Query parameters.
*
* @type string $start_date Minimum start date of the Event.
* @type string $end_date Maximum end date of the Event.
* @type string $eventDate A specific Event date for the Query.
* @type bool $hide_upcoming Hide events that are not on eventDate, internal usage
* @type int $venue Select events from a specific Venue
* @type int $organizer Select events from a specific Organizer
* @type string $eventDisplay How to display the Events, internal usage
* }
*
* @param bool $full Whether to return an array of event posts (default) or the query object
* to fetch them.
*
* @return array|WP_Query A list of event posts matching the query arguments or a WP_Query instance
* if the `$full` argument is set to `true`.
*/
function tribe_get_events( $args = [], $full = false ) {
if ( empty ( $args['eventDisplay'] ) ) {
$args['eventDisplay'] = 'custom';
}
return apply_filters( 'tribe_get_events', Tribe__Events__Query::getEvents( $args, $full ), $args, $full );
}
/**
* Returns the current event post object (if there is one) or else null.
*
* Optionally the post object or ID of an event can be passed in and,
* again, the event post object will be returned if possible.
*
* @param $event
*
* @return null|WP_Post
* @category Events
*/
function tribe_events_get_event( $event = null ) {
global $post;
if ( null === $event ) {
return $post;
}
if ( $event instanceof WP_Post && Tribe__Events__Main::POSTTYPE === get_post_type( $event ) ) {
return $post;
}
if ( is_numeric( $event ) && $event == intval( $event ) ) {
$event = get_post( $event );
if ( null !== $event && Tribe__Events__Main::POSTTYPE === get_post_type( $event ) ) {
return $event;
}
}
return null;
}
/**
* All Day Event Test
*
* Returns true if the event is an all day event
*
* @param int $postId (optional)
*
* @return bool
* @category Events
*/
function tribe_event_is_all_day( $postId = null ) {
$output = Tribe__Date_Utils::is_all_day( tribe_get_event_meta( $postId, '_EventAllDay', true ) );
return apply_filters( 'tribe_event_is_all_day', $output, $postId );
}
/**
* Multi-day Event Test
*
* Returns true if the event spans multiple days
*
* @param int $postId (optional)
*
* @return bool true if event spans multiple days
* @category Events
*/
function tribe_event_is_multiday( $postId = null ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$start = tribe_get_start_date( $postId, true, Tribe__Date_Utils::DBDATETIMEFORMAT );
$end = tribe_get_end_date( $postId, true, Tribe__Date_Utils::DBDATETIMEFORMAT );
$end = strtotime( $end );
$output = ( $end > strtotime( tribe_end_of_day( $start ) ) );
return apply_filters( 'tribe_event_is_multiday', $output, $postId, $start, $end );
}
/**
* Detect if an Event is Past
*
* Returns true if the current time is past the event end time
*
* @param null $event
*
* @return bool
*/
function tribe_is_past_event( $event = null ) {
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
// Are we using the site wide timezone or the local event timezone?
$timezone_name = Tribe__Events__Timezones::EVENT_TIMEZONE === Tribe__Events__Timezones::mode()
? Tribe__Events__Timezones::get_event_timezone_string( $event->ID )
: Tribe__Events__Timezones::wp_timezone_string();
$format = 'Y-m-d G:i';
$end_date = tribe_get_end_date( $event, false, $format );
// Try to create a a current and end date with the timezone to avoid using the WP timezone if is not the setup case.
try {
$timezone = Timezones::build_timezone_object( $timezone_name );
$current = date_create( 'now', $timezone );
$end = date_create( $end_date, $timezone );
} catch ( Exception $exception ) {
$current = false;
$end = false;
}
// If date_create throws an error or was not created correctly we fallback to the original solution
if ( false === $current || false === $end ) {
$gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : ' ' . get_option( 'gmt_offset' );
$gmt_offset = str_replace( [ '.25', '.5', '.75' ], [ ':15', ':30', ':45' ], $gmt_offset );
return strtotime( $end_date . $gmt_offset ) < time();
} else {
return $current > $end;
}
}
/**
* Returns an array terms `term_id` from the taxonomy `tribe_cat` for a given event.
*
* @since 3.0.0
* @since 6.0.11 Type hinting the return to array.
*
* @uses wp_get_object_terms()
*
* @param int|string|WP_Post $post_id
*
* @return array
*/
function tribe_get_event_cat_ids( $post_id = 0 ): array {
$post_id = Tribe__Events__Main::postIdHelper( $post_id );
$terms = get_the_terms( $post_id, Tribe__Events__Main::TAXONOMY );
if ( $terms instanceof WP_Error ) {
return [];
}
// Makes sure we are not throwing fatals on PHP 8.0.
if ( empty( $terms ) ) {
return [];
}
$terms = array_values( array_filter( $terms, static function ( $term ) {
return $term instanceof WP_Term;
} ) );
return wp_list_pluck( $terms, 'term_id' );
}
/**
* Event Category slugs
*
* Display the event category ID as a class for events wrapper
*
* @uses wp_get_object_terms()
* @category Events
*/
function tribe_get_event_cat_slugs( $post_id = 0 ) {
$post_id = Tribe__Events__Main::postIdHelper( $post_id );
$terms = get_the_terms( $post_id, Tribe__Events__Main::TAXONOMY );
/**
* Returns an empty array on events that aren't assigned
* to any category or when $terms generates an error.
*
* @since 6.0.11
*
* @return array
*/
if ( empty ( $terms ) || $terms instanceof WP_Error ) {
return [];
}
$terms = array_values( array_filter(
$terms,
static function ( $term ) {
return $term instanceof WP_Term;
}
) );
$slugs = wp_list_pluck( $terms, 'slug' );
return apply_filters( 'tribe_get_event_cat_slugs', $slugs, $post_id );
}
/**
* Single event taxonomy terms
*
* Get the term list by taxonomy (default categories) for a single event
*
* @param int $post_id
* @param array $args
*
* @return string HTML string of taxonomy terms
* @category Events
*/
function tribe_get_event_taxonomy( $post_id = null, $args = [] ) {
$post_id = Tribe__Events__Main::postIdHelper( $post_id );
$tribe_ecp = Tribe__Events__Main::instance();
$defaults = [
'taxonomy' => $tribe_ecp->get_event_taxonomy(),
'before' => '
';
echo apply_filters( 'tribe_events_after_html', $after );
}
/**
* Prints out or returns classes on an event wrapper
*
* @param $event |0 post id or object
* @param $echo |true
*
**@category Events
*/
function tribe_events_event_classes( $event = 0, $echo = true ) {
global $post, $wp_query;
// May be called when the global $post object does not exist - ie during ajax loads of various views
// ... creating a dummy object allows the method to proceed semi-gracefully (interim measure only)
//If $post object doesn't exist and an $event_id wasn't specified, then use a dummy object
if ( $event instanceof WP_Post ) {
$event_id = $event->ID;
} elseif ( $event !== 0 ) {
$event_id = $event;
} else {
$event_id = $post->ID;
}
if ( ! $event_id ) {
return '';
}
$classes = [ 'type-tribe_events', 'post-' . $event_id, 'tribe-clearfix' ];
$tribe_cat_slugs = tribe_get_event_cat_slugs( $event_id );
foreach ( $tribe_cat_slugs as $tribe_cat_slug ) {
if ( ! empty( $tribe_cat_slug ) ) {
$classes[] = 'tribe-events-category-' . $tribe_cat_slug;
}
}
if ( $venue_id = tribe_get_venue_id( $event_id ) ) {
$classes[] = 'tribe-events-venue-' . $venue_id;
}
foreach ( tribe_get_organizer_ids( $event_id ) as $organizer_id ) {
$classes[] = 'tribe-events-organizer-' . $organizer_id;
}
// added first class for css
if ( ( $wp_query->current_post == 0 ) && ! tribe_is_day() ) {
$classes[] = 'tribe-events-first';
}
// added last class for css
if ( $wp_query->current_post == $wp_query->post_count - 1 ) {
$classes[] = 'tribe-events-last';
}
// Mark 'featured' events
if ( tribe( 'tec.featured_events' )->is_featured( $event_id ) ) {
$classes[] = 'tribe-event-featured';
}
/**
* Filters the event wrapper classes before they are returned
*
* @since 4.6.20 added the $event_id parameter
*
* @param array $classes The classes that will be returned
* @param int $event_id Current event ID
*/
$classes = apply_filters( 'tribe_events_event_classes', $classes, $event_id );
if ( $echo ) {
echo implode( ' ', $classes );
} else {
return implode( ' ', $classes );
}
}
/**
* Prints out data attributes used in the template header tags
*
* @param string|null $current_view
*
**@category Events
*/
function tribe_events_the_header_attributes( $current_view = null ) {
if ( ! $wp_query = tribe_get_global_query_object() ) {
return;
}
$attrs = [];
$current_view = ! empty( $current_view ) ? $current_view : basename( tribe_get_current_template() );
// wp_title was deprecated in WordPress 4.4. Fetch the document title with the new function (added in 4.4) if available
if ( function_exists( 'wp_get_document_title' ) ) {
$attrs['data-title'] = wp_get_document_title();
} else {
$attrs['data-title'] = wp_title( '|', false, 'right' );
}
$attrs['data-viewtitle'] = tribe_get_events_title( true );
if ( has_filter( 'tribe_events_mobile_breakpoint' ) ) {
$attrs['data-mobilebreak'] = tribe_get_mobile_breakpoint();
}
$attrs = apply_filters( 'tribe_events_header_attributes', $attrs, $current_view );
foreach ( $attrs as $attr => $value ) {
echo " $attr=" . '"' . esc_attr( $value ) . '"';
}
}
/**
* Return an array with the days of the week, numbered with respect to the start_of_week WP option
*
* @param string $format the display format for the days of the week
*
* @return array Days of the week.
**@category Events
*/
function tribe_events_get_days_of_week( $format = null ) {
switch ( $format ) {
case 'min' :
$days_of_week = Tribe__Events__Main::instance()->daysOfWeekMin;
break;
case 'short' :
$days_of_week = Tribe__Events__Main::instance()->daysOfWeekShort;
break;
default:
$days_of_week = Tribe__Events__Main::instance()->daysOfWeek;
break;
}
$start_of_week = get_option( 'start_of_week', 0 );
for ( $i = 0; $i < $start_of_week; $i ++ ) {
$day = $days_of_week[ $i ];
unset( $days_of_week[ $i ] );
$days_of_week[ $i ] = $day;
}
return apply_filters( 'tribe_events_get_days_of_week', $days_of_week );
}
/**
* Display Cost Field
*
* Conditional tag to determine if the cost field should be shown in the admin editors.
*
* @return bool
* @category Cost
*/
function tribe_events_admin_show_cost_field() {
$modules = null;
if ( class_exists( 'Tribe__Tickets__Tickets' ) ) {
$modules = Tribe__Tickets__Tickets::modules();
}
$event_origin = get_post_meta( get_the_ID(), '_EventOrigin', true );
$show_cost = empty( $modules ) ||
class_exists( 'Tribe__Events__Tickets__Eventbrite__Main' ) ||
in_array(
$event_origin,
apply_filters( 'tribe_events_admin_show_cost_field_origin', [ 'community-events' ] )
);
return apply_filters( 'tribe_events_admin_show_cost_field', $show_cost, $modules );
}
/**
* Get an event's cost
*
* @param null|int $post_id (optional)
* @param bool $with_currency_symbol Include the currency symbol
*
* @return string Cost of the event.
* @category Cost
*/
function tribe_get_cost( $post_id = null, $with_currency_symbol = false ) {
$tribe_ecp = Tribe__Events__Main::instance();
$post_id = Tribe__Events__Main::postIdHelper( $post_id );
$cost_utils = tribe( 'tec.cost-utils' );
$cost = $cost_utils->get_formatted_event_cost( $post_id, $with_currency_symbol );
return apply_filters( 'tribe_get_cost', $cost, $post_id, $with_currency_symbol );
}
/**
* Returns the event cost complete with currency symbol.
*
* Essentially an alias of tribe_get_cost(), as if called with the $withCurrencySymbol
* argument set to true. Useful for callbacks.
*
* @param null $postId
*
* @return mixed|void
* @category Cost
*/
function tribe_get_formatted_cost( $postId = null ) {
return apply_filters( 'tribe_get_formatted_cost', tribe_get_cost( $postId, true ) );
}
/**
* Get the minimum cost of all events.
*
* @return int the minimum cost.
* @category Cost
*/
function tribe_get_minimum_cost() {
return tribe( 'tec.cost-utils' )->get_minimum_cost();
}
/**
* Get the maximum cost of all events.
*
* @return int the maximum cost.
* @category Cost
*/
function tribe_get_maximum_cost() {
return tribe( 'tec.cost-utils' )->get_maximum_cost();
}
/**
* Indicates if there events without a specific cost (as distinct from
* free events).
*
* @return bool if uncosted events exist
*/
function tribe_has_uncosted_events() {
return tribe( 'tec.cost-utils' )->has_uncosted_events();
}
/**
* Event in Category Conditional
*
* Returns true if the event is in the specified category slug
*
* @param string $event_cat_slug
* @param int $event_id
*
* @return bool
* @category Events
*/
function tribe_event_in_category( $event_cat_slug, $event_id = null ) {
if ( empty( $event_id ) ) {
$event_id = get_the_ID();
}
$term = term_exists( $event_cat_slug, Tribe__Events__Main::TAXONOMY );
if (
tribe_is_event( $event_id )
&& is_object_in_term( $event_id, Tribe__Events__Main::TAXONOMY, [ $term['term_id'] ] )
) {
$return = true;
} else {
$return = false;
}
return apply_filters( 'tribe_event_in_category', $return );
}
/**
* Return the featured image for an event (within the loop automatically will get event ID).
*
* Where possible, the image will be returned as a well formed tag contained in a link
* element and wrapped in a div used for targetting featured images from stylesheet. By setting
* the two final and optional parameters to false, however, it is possible to retrieve only
* the image URL itself.
*
* @param int $post_id
* @param string $size
* @param bool $link
* @param bool $wrapper
*
* @return string
* @category Events
*
*/
function tribe_event_featured_image( $post_id = null, $size = 'full', $link = true, $wrapper = true ) {
if ( is_null( $post_id ) ) {
$post_id = get_the_ID();
}
/**
* Provides an opportunity to modify the featured image size.
*
* @param string $size
* @param int $post_id
*/
$size = apply_filters( 'tribe_event_featured_image_size', $size, $post_id );
$featured_image = $wrapper
? get_the_post_thumbnail( $post_id, $size )
: wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size, false );
if ( is_array( $featured_image ) ) {
$featured_image = $featured_image[0];
}
/**
* Controls whether the featured image should be wrapped in a link
* or not.
*
* @param bool $link
*/
if ( ! empty( $featured_image ) && apply_filters( 'tribe_event_featured_image_link', $link ) ) {
$featured_image = '' . $featured_image . '';
}
/**
* Whether to wrap the featured image in our standard div (used to
* assist in targeting featured images from stylesheets, etc).
*
* @param bool $wrapper
*/
if ( ! empty( $featured_image ) && apply_filters( 'tribe_events_featured_image_wrap', $wrapper ) ) {
$featured_image = '
' . $featured_image . '
';
}
/**
* Provides an opportunity to modify the featured image HTML.
*
* @param string $featured_image
* @param int $post_id
* @param string $size
*/
return apply_filters( 'tribe_event_featured_image', $featured_image, $post_id, $size );
}
/**
* Return the details of the start/end date/time.
*
* The highest level means of customizing this function's output is simply to adjust the date format settings under
* Events > Settings > Display, and WordPress time formats (via the General Settings admin screen).
* Beyond that, however, there are two filters which can be used to exercise further control here.
*
* The first is 'tribe_events_event_schedule_details_formatting' which allows an array of format settings to be
* altered - it's basic make-up is as a simple set of key:value pairs as follows.
*
* "show_end_time": for single day events only (not including all day events) it may not always be desirable to
* include the end time. In that situation, this setting can be set to false and the end time will not be
* displayed.
*
* "time": if it is undesirable to show times and only dates should be displayed then this setting can be set to
* false. If it is false it will by extension cause 'show_end_time' to be false.
*
* The resulting string can also be caught and manipulated, or completely overridden, using the
* 'tribe_events_event_schedule_details' filter, should none of the above settings be sufficient.
*
* @todo [BTRIA-644]: Use tribe_get_datetime_format() and related functions if possible.
*
* @param int|null $event The event post ID, or `null` to use the global event.
* @param string $before A string to prepend before the schedule details.
* @param string $after A string to append after the schedule details.
* @param bool $html Whether to use HTML elements in the output string or not; defaults to `true`.
*
* @return string The human-readable event schedule details formatted according to the current settings.
* @category Events
*/
function tribe_events_event_schedule_details( $event = null, $before = '', $after = '', $html = true ) {
static $cache_var_name = __FUNCTION__;
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
if ( is_numeric( $event ) ) {
$event = get_post( $event );
}
// if the post is password protected, don't return the schedule details
if ( post_password_required( $event ) ) {
return '';
}
$cache_details = tribe_get_var( $cache_var_name, [] );
$cache_details_key = "{$event->ID}:{$before}:{$after}:{$html}";
if ( ! isset( $cache_details[ $cache_details_key ] ) ) {
$inner = $html ? '' : '';
$format = '';
$date_without_year_format = tribe_get_date_format();
$date_with_year_format = tribe_get_date_format( true );
$time_format = get_option( 'time_format' );
$datetime_separator = tribe_get_option( 'dateTimeSeparator', ' @ ' );
$time_range_separator = tribe_get_option( 'timeRangeSeparator', ' - ' );
$settings = [
'show_end_time' => true,
'time' => true,
];
$settings = wp_parse_args( apply_filters( 'tribe_events_event_schedule_details_formatting', $settings ), $settings );
if ( ! $settings['time'] ) {
$settings['show_end_time'] = false;
}
/**
* @var $show_end_time
* @var $time
*/
extract( $settings );
$format = $date_with_year_format;
/**
* If a yearless date format should be preferred.
*
* By default, this will be true if the event starts and ends in the current year.
*
* @param bool $use_yearless_format
* @param WP_Post $event
*/
$use_yearless_format = apply_filters( 'tribe_events_event_schedule_details_use_yearless_format',
(
tribe_get_start_date( $event, false, 'Y' ) === date_i18n( 'Y' )
&& tribe_get_end_date( $event, false, 'Y' ) === date_i18n( 'Y' )
),
$event
);
if ( $use_yearless_format ) {
$format = $date_without_year_format;
}
if ( tribe_event_is_multiday( $event ) ) { // multi-date event
$format2ndday = apply_filters( 'tribe_format_second_date_in_range', $format, $event );
if ( tribe_event_is_all_day( $event ) ) {
$inner .= tribe_get_start_date( $event, true, $format );
$inner .= ( $html ? '' : '' ) . $time_range_separator;
$inner .= $html ? '' : '';
$end_date_full = tribe_get_end_date( $event, true, Tribe__Date_Utils::DBDATETIMEFORMAT );
$end_date_full_timestamp = strtotime( $end_date_full );
// if the end date is <= the beginning of the day, consider it the previous day
if ( $end_date_full_timestamp <= strtotime( tribe_beginning_of_day( $end_date_full ) ) ) {
$end_date = tribe_format_date( $end_date_full_timestamp - DAY_IN_SECONDS, false, $format2ndday );
} else {
$end_date = tribe_get_end_date( $event, false, $format2ndday );
}
$inner .= $end_date;
} else {
$inner .= tribe_get_start_date( $event, false, $format ) . ( $time ? $datetime_separator . tribe_get_start_date( $event, false, $time_format ) : '' );
$inner .= ( $html ? '' : '' ) . $time_range_separator;
$inner .= $html ? '' : '';
$inner .= tribe_get_end_date( $event, false, $format2ndday ) . ( $time ? $datetime_separator . tribe_get_end_date( $event, false, $time_format ) : '' );
}
} elseif ( tribe_event_is_all_day( $event ) ) { // all day event
$inner .= tribe_get_start_date( $event, true, $format );
} else { // single day event
if ( tribe_get_start_date( $event, false, 'g:i A' ) === tribe_get_end_date( $event, false, 'g:i A' ) ) { // Same start/end time
$inner .= tribe_get_start_date( $event, false, $format ) . ( $time ? $datetime_separator . tribe_get_start_date( $event, false, $time_format ) : '' );
} else { // defined start/end time
$inner .= tribe_get_start_date( $event, false, $format ) . ( $time ? $datetime_separator . tribe_get_start_date( $event, false, $time_format ) : '' );
$inner .= ( $html ? '' : '' ) . ( $show_end_time ? $time_range_separator : '' );
$inner .= $html ? '' : '';
$inner .= ( $show_end_time ? tribe_get_end_date( $event, false, $time_format ) : '' );
}
}
$inner .= $html ? '' : '';
$cache_details[ $cache_details_key ] = $inner;
tribe_set_var( $cache_var_name, $cache_details );
}
/**
* Provides an opportunity to modify the *inner* schedule details HTML (ie before it is
* wrapped).
*
* @param string $inner_html the output HTML
* @param int $event_id post ID of the event we are interested in
*/
$inner = apply_filters( 'tribe_events_event_schedule_details_inner', $cache_details[ $cache_details_key ], $event->ID );
// Wrap the schedule text
$schedule = $before . $inner . $after;
/**
* Provides an opportunity to modify the schedule details HTML for a specific event after
* it has been wrapped in the before and after markup.
*
* @param string $schedule the output HTML
* @param int $event_id post ID of the event we are interested in
* @param string $before part of the HTML wrapper that was prepended
* @param string $after part of the HTML wrapper that was appended
*/
return apply_filters( 'tribe_events_event_schedule_details', $schedule, $event->ID, $before, $after );
}
/**
* Return the short details of the start/end date/time.
*
* @see tribe_events_event_schedule_details() for the format of the schedule details.
*
* @param int|null $event The event post ID, or `null` to use the global event.
* @param string $before A string to prepend before the schedule details.
* @param string $after A string to append after the schedule details.
* @param bool $html Whether to use HTML elements in the output string or not; defaults to `true`.
*
* @return string The human-readable event short schedule details formatted according to the current settings.
*/
function tribe_events_event_short_schedule_details( $event = null, $before = '', $after = '', $html = true ) {
static $cache_var_name = __FUNCTION__;
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
if ( is_numeric( $event ) ) {
$event = get_post( $event );
}
// if the post is password protected, don't return the schedule details
if ( post_password_required( $event ) ) {
return '';
}
$cache_details = tribe_get_var( $cache_var_name, [] );
$cache_details_key = "{$event->ID}:{$before}:{$after}:{$html}";
if ( ! isset( $cache_details[ $cache_details_key ] ) ) {
if ( tribe_event_is_multiday( $event ) ) {
// Multiday event.
$inner = tribe_events_event_schedule_details( $event, $before, $after, $html );
} elseif ( tribe_event_is_all_day( $event ) ) {
// All day event.
$inner = esc_html_x( 'All day', 'All day label for event', 'the-events-calendar' );
} else {
// Single day event.
$inner = $html ? '' : '';
$time_format = get_option( 'time_format' );
if ( tribe_get_start_date( $event, false, 'g:i A' ) === tribe_get_end_date( $event, false, 'g:i A' ) ) {
// Same start/end time.
$inner .= tribe_get_start_date( $event, false, $time_format );
} else {
// Different start/end time.
$time_range_separator = tribe_get_option( 'timeRangeSeparator', ' - ' );
$inner .= tribe_get_start_date( $event, false, $time_format );
$inner .= $html ? '' : '';
$inner .= $time_range_separator;
$inner .= $html ? '' : '';
$inner .= tribe_get_end_date( $event, false, $time_format );
}
$inner .= $html ? '' : '';
}
$cache_details[ $cache_details_key ] = $inner;
tribe_set_var( $cache_var_name, $cache_details );
}
/**
* Provides an opportunity to modify the *inner* short schedule details HTML
* (ie before it is wrapped).
*
* @param string $inner_html the output HTML.
* @param int $event_id post ID of the event we are interested in.
*/
$inner = apply_filters( 'tribe_events_event_short_schedule_details_inner', $cache_details[ $cache_details_key ], $event->ID );
// Wrap the schedule text
$schedule = $before . $inner . $after;
/**
* Provides an opportunity to modify the short schedule details HTML for a specific event
* after it has been wrapped in the before and after markup.
*
* @param string $schedule the output HTML.
* @param int $event_id post ID of the event we are interested in.
* @param string $before part of the HTML wrapper that was prepended.
* @param string $after part of the HTML wrapper that was appended.
*/
return apply_filters( 'tribe_events_event_short_schedule_details', $schedule, $event->ID, $before, $after );
}
/**
* Returns json for javascript templating functions throughout the plugin.
*
* @deprecated 6.0.0 We have no direct replacement as this can be incredibly bad for performance.
*
* @param mixed $__deprecated
* @param array $additional
*
* @return string
*/
function tribe_events_template_data( $__deprecated = null, array $additional = [] ) {
_deprecated_function( __METHOD__, '6.0.0', 'With no direct replacements.' );
$json = tec_events_get_current_view()->get_template()->get_values();
if ( ! empty( $additional ) ) {
$json = array_merge( (array) $json, $additional );
}
$json = apply_filters( 'tribe_events_template_data_array', $json, $__deprecated, $additional );
$json = tribe_prepare_for_json_deep( $json );
return json_encode( $json );
}
/**
* Using a filter that each view will hook in it allows templates to get what is the current view being rendered.
*
* @since 6.0.0
*
* @return null|\Tribe\Events\Views\V2\View_Interface
*/
function tec_events_get_current_view() {
/**
* Which view is currently being rendered.
*
* @since 6.0.0
*
* @pararm null|\Tribe\Events\Views\V2\View_Interface $view Which view instance we are currently rendering.
*/
return apply_filters( 'tec_events_get_current_view', null );
}
/**
* Display the Events Calendar promo banner
*
* @param bool $echo Whether or not to echo the banner, if false, it's returned
*
* @return string
**@category Events
*
*/
function tribe_events_promo_banner( $echo = true ) {
if ( tribe_get_option( 'donate-link', false ) == true && ! tribe_is_bot() ) {
$promo = apply_filters( 'tribe_events_promo_banner_message', sprintf( esc_html__( 'Calendar powered by %s', 'the-events-calendar' ), '' . esc_html__( 'The Events Calendar', 'the-events-calendar' ) . '' ) );
$html = apply_filters( 'tribe_events_promo_banner', sprintf( '
%s
', $promo ), $promo );
if ( $echo ) {
echo $html;
} else {
return $html;
}
}
}
/**
* Returns the URL for use in the tribe bar form's action attribute.
*
* @return string URL for current tribe bar form action.
*/
function tribe_events_get_current_filter_url() {
global $wp;
$url = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
return apply_filters( 'tribe_events_get_current_filter_url', $url );
}
/**
* Get and increment tab index in form fields
*
*/
function tribe_events_get_tab_index() {
$tribe_events = Tribe__Events__Main::instance();
return apply_filters( 'tribe_events_tab_index', $tribe_events->tabIndex() );
}
/**
* Echo and increment tab index in form fields
*
*/
function tribe_events_tab_index() {
echo tribe_events_get_tab_index();
}
if ( ! function_exists( 'tribe_events_is_view_enabled' ) ) {
/**
* Check if a particular view is enabled
*
* @since 6.0.0 Updated to use \Tribe\Events\Views\V2\Manager.
*
* @param string $view Slug of view to check.
*
* @return bool
**/
function tribe_events_is_view_enabled( $view ) {
$manager = tribe( \Tribe\Events\Views\V2\Manager::class );
$public_views = $manager->get_publicly_visible_views();
$enabled = isset( $public_views[ $view ] );
return apply_filters( 'tribe_events_is_view_enabled', $enabled, $view, array_keys( $public_views ) );
}
}
/**
* A Excerpt method used across the board on our Events Plugin Suite.
*
* By default it removes all shortcodes, the reason for this is that shortcodes added by other plugins/themes
* may not have been registered by the time our ajax responses are generated. To avoid leaving unparsed
* shortcodes in our excerpts then we strip out anything that looks like one.
*
* @param WP_Post|int|null $post The Post Object|ID, if null defaults to `get_the_ID()`
* @param array $allowed_html The wp_kses compatible array
* @param boolean $skip_postdata_manipulation Optional. Defaults to false. When true, the resetting of global $post variable is disabled. (Useful for
* some contexts like month view.)
*
* @return string|null Will return null on Bad Post Instances
* @category Events
*
*/
function tribe_events_get_the_excerpt( $post = null, $allowed_html = null, $skip_postdata_manipulation = false ) {
static $cache_var_name = __FUNCTION__;
$cache_excerpts = tribe_get_var( $cache_var_name, [] );
// If post is not numeric or instance of WP_Post it defaults to the current Post ID
if ( ! is_numeric( $post ) && ! $post instanceof WP_Post ) {
$post = get_the_ID();
}
// If not a WP_Post we try to fetch it as one
if ( is_numeric( $post ) ) {
$post = WP_Post::get_instance( $post );
}
// Prevent Non usable $post instances
if ( ! $post instanceof WP_Post ) {
return null;
}
// Default Allowed HTML
if ( ! is_array( $allowed_html ) ) {
$base_attrs = [
'class' => [],
'id' => [],
'style' => [],
];
$allowed_html = [
'a' => [
'class' => [],
'id' => [],
'style' => [],
'href' => [],
'rel' => [],
'target' => [],
],
'b' => $base_attrs,
'strong' => $base_attrs,
'em' => $base_attrs,
'span' => $base_attrs,
'ul' => $base_attrs,
'li' => $base_attrs,
'ol' => $base_attrs,
];
}
$post_id = $post->ID;
/**
* Allow developers to filter what are the allowed HTML on the Excerpt
*
* @link https://codex.wordpress.org/Function_Reference/wp_kses
*
* @param WP_Post $post The current post object.
*
* @param array Must be compatible to wp_kses structure.
*/
$allowed_html = apply_filters( 'tribe_events_excerpt_allowed_html', $allowed_html, $post );
/**
* Allow shortcodes to be Applied on the Excerpt or not
*
* @param bool Whether shortcodes are allowed in the Event excerpt or not.
* @param WP_Post $post The current post object.
*/
$allow_shortcodes = apply_filters( 'tribe_events_excerpt_allow_shortcode', false, $post );
/**
* Filter to stop removal of shortcode markup in the excerpt.
*
* This will remove all text that resembles a shortcode [shortcode 5].
*
* @since 5.1.0
*
* @param bool $remove_shortcodes Whether shortcodes content should be removed from the excerpt or not.
* @param WP_Post $post The current post object.
*/
$remove_shortcodes = apply_filters( 'tribe_events_excerpt_shortcode_removal', true, $post );
/**
* Filters whether the content produced by block editor blocks should be removed or not from the excerpt.
*
* If truthy then block whose content does not belong in the excerpt, will be removed.
* This removal is done using WordPress Core `excerpt_remove_blocks` function.
*
* @see excerpt_remove_blocks() The WordPress Core function that will handle the block removal from the excerpt.
* @since 5.1.0
*
* @param WP_Post $post The current post object.
*
* @param bool $remove_blocks Whether blocks whose content should not be part of the excerpt should be removed
* or not from the excerpt.
*/
$remove_blocks = (bool) apply_filters( 'tribe_events_excerpt_blocks_removal', true, $post );
$cache_excerpts_key = implode( ':', [
$post->ID,
$skip_postdata_manipulation,
$allow_shortcodes,
$remove_shortcodes,
json_encode( $allowed_html ),
] );
if ( ! isset( $cache_excerpts[ $cache_excerpts_key ] ) ) {
// Get the Excerpt or content based on what is available.
$excerpt = has_excerpt( $post->ID ) ? $post->post_excerpt : $post->post_content;
/*
* If blocks should be removed from the excerpt, remove them now.
*/
if ( $remove_blocks && function_exists( 'excerpt_remove_blocks' ) ) {
$excerpt = excerpt_remove_blocks( $excerpt );
}
// If shortcode filter is enabled let's process them.
if ( $allow_shortcodes ) {
$excerpt = do_shortcode( $excerpt );
}
// Remove all shortcode Content before removing HTML
if ( $remove_shortcodes ) {
$excerpt = preg_replace( '#\[.+\]#U', '', $excerpt );
}
// Remove "all" HTML based on what is allowed
$excerpt = wp_kses( $excerpt, $allowed_html );
if ( ! has_excerpt( $post->ID ) ) {
// Temporarily alter the global post in preparation for our filters.
$global_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
$GLOBALS['post'] = $post;
// We will only trim Excerpt if it comes from Post Content
/**
* Filter the number of words in an excerpt.
*
* @param int $number The number of words. Default 55.
*/
$excerpt_length = apply_filters( 'excerpt_length', 55 );
/**
* Filter the string in the "more" link displayed after a trimmed excerpt.
*
* @param string $more_string The string shown within the more link.
*/
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
// Now we actually trim it
$excerpt = wp_trim_words( $excerpt, $excerpt_length, $excerpt_more );
// Original post is back in action!
$GLOBALS['post'] = $global_post;
}
$cache_excerpts[ $cache_excerpts_key ] = wpautop( $excerpt );
tribe_set_var( $cache_var_name, $cache_excerpts );
}
if ( ! $skip_postdata_manipulation ) {
// Setup post data to be able to use WP template tags
setup_postdata( $post );
}
/**
* Filter the event excerpt used in various views.
*
* @param string $excerpt
* @param WP_Post $post
*/
$excerpt = apply_filters( 'tribe_events_get_the_excerpt', $cache_excerpts[ $cache_excerpts_key ], $post );
if ( ! $skip_postdata_manipulation ) {
wp_reset_postdata();
}
return $excerpt;
}
/**
* Returns the latest known event end date, which can be expected to be a string
* in MySQL datetime format (unless some other specific format is provided).
*
* If this is impossible to determine it will return boolean false.
*
* @param string $format
*
* @return mixed bool|string
* @category Events
*
*/
function tribe_events_latest_date( $format = Tribe__Date_Utils::DBDATETIMEFORMAT ) {
// Check if the latest end date is already known
$latest = tribe_get_option( 'latest_date', false );
if ( false !== $latest ) {
return Tribe__Date_Utils::reformat( $latest, $format );
}
// If not, try to determine now
Tribe__Events__Dates__Known_Range::instance()->rebuild_known_range();
$latest = tribe_get_option( 'latest_date', false );
if ( false !== $latest ) {
return Tribe__Date_Utils::reformat( $latest, $format );
}
return false;
}
/**
* Returns the earliest known event start date, which can be expected to be a string
* in MySQL datetime format (unless some other specific format is provided).
*
* If this is impossible to determine it will return boolean false.
*
* @param string $format
*
* @return mixed bool|string
* @category Events
*
*/
function tribe_events_earliest_date( $format = Tribe__Date_Utils::DBDATETIMEFORMAT ) {
// Check if the earliest start date is already known
$earliest = tribe_get_option( 'earliest_date', false );
if ( false !== $earliest ) {
return Tribe__Date_Utils::reformat( $earliest, $format );
}
// If not, try to determine now
Tribe__Events__Dates__Known_Range::instance()->rebuild_known_range();
$earliest = tribe_get_option( 'earliest_date', false );
if ( false !== $earliest ) {
return Tribe__Date_Utils::reformat( $earliest, $format );
}
return false;
}
/**
* Get the default value for a field
*
* @param string $field
*
* @return mixed
*/
function tribe_get_default_value( $field ) {
$field = strtolower( $field );
$defaults = Tribe__Events__Main::instance()->defaults();
$value = call_user_func( [ $defaults, $field ] );
return $value;
}
/**
* Gets the render context of the given query
*
* @param WP_Query $query Query object
*
* @return string
*/
function tribe_get_render_context( $query = null ) {
global $wp_query;
if ( ! $query instanceof WP_Query ) {
$query = $wp_query;
}
if ( empty( $query->query['tribe_render_context'] ) ) {
return 'default';
}
return $query->query['tribe_render_context'];
}
/**
* Returns or echoes a url to a file in the Events Calendar plugin resources directory
*
* @param string $resource the filename of the resource
* @param bool $echo whether or not to echo the url
* @param string $root_dir directory to hunt for resource files (src or common)
*
* @return string
**@category Events
*/
function tribe_events_resource_url( $resource, $echo = false, $root_dir = 'src' ) {
$extension = pathinfo( $resource, PATHINFO_EXTENSION );
if ( 'src' !== $root_dir ) {
return tribe_resource_url( $resource, $echo, $root_dir );
}
$resources_path = $root_dir . '/resources/';
switch ( $extension ) {
case 'css':
$resource_path = $resources_path . 'css/';
break;
case 'js':
$resource_path = $resources_path . 'js/';
break;
case 'scss':
$resource_path = $resources_path . 'scss/';
break;
default:
$resource_path = $resources_path;
break;
}
$path = $resource_path . $resource;
$file = wp_normalize_path( Tribe__Events__Main::instance()->plugin_path . $path );
// Turn the Path into a URL
$url = plugins_url( basename( $file ), $file );
/**
* Deprecated the tribe_events_resource_url filter in 4.0 in favor of tribe_resource_url. Remove in 5.0
*/
$url = apply_filters( 'tribe_events_resource_url', $url, $resource );
if ( $echo ) {
echo esc_url( $url );
}
return $url;
}
/**
* Utility function to compile separated lists.
*
* @param string $body
* @param string $separator
* @param string $field
*
* @return string
*/
function tribe_separated_field( $body, $separator, $field ) {
$body_and_separator = $body ? $body . $separator : $body;
return $field ? $body_and_separator . $field : $body;
}
/**
* Tests if we are on the site homepage and if it is set to display the main events page.
*
* As WordPress front page it might be different from is_home, if we have a front page on the reading options and
* if the User is on that page, this function will return true otherwise will return false. So either if the User has
* the frontpage set on the reading options and the User is visiting this page.
*
* Another consideration about this is it might behave as a WordPress function which means after any Ajax action is
* fired the result of call this function via Ajax might not be the expected result so ideally can be used to test
* if you are on the front page on first load of the page only.
*
* @since 4.6.9
*
* @return bool
*/
function tribe_is_events_front_page() {
$wp_query = tribe_get_global_query_object();
if ( ! $wp_query instanceof WP_Query ) {
return false;
}
$events_as_front_page = tribe_get_option( 'front_page_event_archive', false );
// If the reading option has an events page as front page and we are on that page is on the home of events.
return (
$wp_query->is_main_query()
&& $events_as_front_page
&& $wp_query->tribe_is_event
&& true === get_query_var( 'tribe_events_front_page' )
);
}
/**
* Test if we are on the home of events either if is set to frontpage or the default /events page.
*
* Utility function to test if we are on the home of events, it makes a test in cases when the page is set to be on
* the frontpage of the site and if the User is on that page is on the homepage or if the User is on the events page
* where the eventDisplay is set to default.
*
* Also consider this might not work as expected inside of Ajax Calls as this one is fired on initial loading of the
* page so be aware of unexpected results via Ajax calls.
*
* @since 4.6.9
*
* @return bool
*/
function tribe_is_events_home() {
$wp_query = tribe_get_global_query_object();
if ( ! $wp_query instanceof WP_Query ) {
return false;
}
if ( tribe_is_events_front_page() ) {
return true;
}
$events_as_front_page = tribe_get_option( 'front_page_event_archive', false );
// If the readme option does not has an event page as front page and if id the 'default' view on the main query
// as is going to set to 'default' when is loading the root of events/ rewrite rule also makes sure is not on
// a taxonomy or a tag.
if (
! $events_as_front_page
&& $wp_query->is_main_query()
&& $wp_query->tribe_is_event // Make sure following conditionals operate only on events
&& ( isset( $wp_query->query['eventDisplay'] ) && 'default' === $wp_query->query['eventDisplay'] )
&& is_post_type_archive()
&& ! is_tax()
&& ! is_tag()
) {
return true;
}
// No condition was true so is not on home of events.
return false;
}
PK qT[d4R 4R
organizer.phpnu [ 0 ) {
$tribe_ecp = Tribe__Events__Main::instance();
// check if $postId is an organizer id
if ( $tribe_ecp->isOrganizer( $postId ) ) {
$organizer_id = $postId;
} else {
$organizer_id = tribe_get_event_meta( $postId, '_EventOrganizerID', true );
}
}
return apply_filters( 'tribe_get_organizer_id', $organizer_id, $postId );
}
/**
* Get the IDs of all organizers associated with an event.
*
* @param int $event_id The event post ID. Defaults to the current event.
*
* @return array
*/
function tribe_get_organizer_ids( $event_id = null ) {
$event_id = Tribe__Events__Main::postIdHelper( $event_id );
$organizer_ids = [];
if ( Tribe__Events__Main::instance()->isEvent( $event_id ) ) {
$organizer_ids = tribe_get_event_meta( $event_id, '_EventOrganizerID', false );
// Protect against storing array items that render false, such as `0`.
$organizer_ids = array_filter( (array) $organizer_ids );
}
return apply_filters( 'tribe_get_organizer_ids', $organizer_ids, $event_id );
}
/**
* An organizers can have two sources the list of ordered items and the meta field associated with organizers,
* where the meta field takes precedence we need to respect the order of the meta order only when the present items
* on the meta field.
*
* @deprecated 4.6.23
* @todo Remove on 4.7
*
* @since 4.6.15
*
* @param array $current
* @param array $ordered
*
* @return array
*/
function tribe_sanitize_organizers( $current = [], $ordered = [] ) {
_deprecated_function( __METHOD__, '4.6.23', 'No longer needed after removing reliance on a separate postmeta field to store the ordering.' );
if ( empty( $ordered ) ) {
return $current;
}
$order = [];
$excluded = [];
foreach ( (array) $current as $post_id ) {
$key = array_search( $post_id, $ordered );
if ( false === $key ) {
$excluded[] = $post_id;
} else {
$order[ $key ] = $post_id;
}
}
// Make sure before the merge the order is ordered by the keys.
ksort( $order );
return array_merge( $order, $excluded );
}
/**
* Get Organizer Label Singular.
* Returns the singular version of the Organizer Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 3.7
* @since5.1.6 remove escaping.
*
* @return string The singular version of the Organizer Label.
*/
function tribe_get_organizer_label_singular() {
/**
* Allows customization of the singular version of the Organizer Label.
* Note: the output of this filter is not escaped!
*
* @since 3.7
* @since5.1.6 Added docblock, remove escaping.
*
* @param string $label The singular version of the Organizer label, defaults to "Organizer" (uppercase)
*/
return apply_filters(
'tribe_organizer_label_singular',
__( 'Organizer', 'the-events-calendar' )
);
}
/**
* Get Organizer Label Plural
* Returns the plural version of the Organizer Label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @since 3.7
* @since5.1.6 remove escaping.
*
* @return string The plural version of the Organizer Label.
*/
function tribe_get_organizer_label_plural() {
/**
* Allows customization of the plural version of the Organizer Label.
* Note: the output of this filter is not escaped!
*
* @since 3.7
* @since5.1.6 Added docblock, remove escaping.
*
* @param string $label The plural version of the Organizer label, defaults to "Organizers" (uppercase).
*/
return apply_filters(
'tribe_organizer_label_plural',
__( 'Organizers', 'the-events-calendar' )
);
}
/**
* Get the organizer label.
*
* Note: the output of this function is not escaped.
* You should escape it wherever you use it!
*
* @param bool $singular TRUE to return the singular label, FALSE to return plural.
*
* @return string
*/
function tribe_get_organizer_label( $singular = true ) {
if ( $singular ) {
return tribe_get_organizer_label_singular();
} else {
return tribe_get_organizer_label_plural();
}
}
/**
* Returns a summary of key information for the specified organizer.
*
* Typically this is a pipe separated format containing the organizer's telephone
* number, email address and website where available.
*
* @param int $post_id Either the organizer or event ID, if none specified, current post is used.
*
* @return string
*/
function tribe_get_organizer_details( $post_id = null ) {
$post_id = Tribe__Events__Main::postIdHelper( $post_id );
$organizer_id = (int) tribe_get_organizer_id( $post_id );
$details = [];
if ( $organizer_id && $tel = tribe_get_organizer_phone() ) {
$details[] = '' . $tel . '';
}
if ( $organizer_id && $email = tribe_get_organizer_email() ) {
$details[] = '' . $email . '';
}
if ( $organizer_id && $link = tribe_get_organizer_website_link() ) {
// $link is a full HTML string () whose components are already escaped, so we don't need create an anchor tag or escape again here
$details[] = '' . $link . '';
}
$html = join( '|', $details );
if ( ! empty( $html ) ) {
$html = '' . $html . '';
}
/**
* Provides an opportunity to modify the organizer details HTML.
*
* @param string $html Organizer details HTML.
* @param int $post_id Either the organizer or event ID.
* @param int $organizer_id The organizer ID.
*/
return apply_filters( 'tribe_get_organizer_details', $html, $post_id, $organizer_id );
}
/**
* Get Organizer
*
* Returns the name of the Organizer
*
* @param int $postId Either event id or organizer id, if none specified, current post is used.
*
* @return string Organizer's Name
*/
function tribe_get_organizer( $postId = null ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$organizer_id = (int) tribe_get_organizer_id( $postId );
$output = '';
if ( $organizer_id > 0 ) {
$output = esc_html( get_the_title( $organizer_id ) );
}
return apply_filters( 'tribe_get_organizer', $output, $organizer_id );
}
/**
* Organizer Test
*
* Returns true or false depending on if the post id has/is an organizer
*
* @param int $postId Either event id or organizer id, if none specified, current post is used.
*
* @return bool
*/
function tribe_has_organizer( $postId = null ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$has_organizer = ( tribe_get_organizer_id( $postId ) > 0 ) ? true : false;
return apply_filters( 'tribe_has_organizer', $has_organizer );
}
/**
* Organizer Email
*
* Returns the Organizer's Email.
*
* @param int $postId Either event id or organizer id, if none specified, current post is used.
* @param bool $antispambot Whether the email should pass through the `antispambot` function or not.
*
* @return string Organizer's Email
*/
function tribe_get_organizer_email( $postId = null, $antispambot = true ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$unfiltered_email = esc_html( tribe_get_event_meta( tribe_get_organizer_id( $postId ), '_OrganizerEmail', true ) );
$filtered_email = $antispambot ? antispambot( $unfiltered_email ) : $unfiltered_email;
/**
* Allows for the organizer email to be filtered.
*
* Please note that obfuscation of email is done in subsequent line using the `antispambot` function.
*
* @param string $filtered_email The organizer email obfuscated using the `antispambot` function.
* @param string $unfiltered_email The organizer email as stored in the database before any filtering or obfuscation is applied.
*/
$filtered_email = apply_filters( 'tribe_get_organizer_email', $filtered_email, $unfiltered_email );
return $filtered_email;
}
/**
* Organizer Page Link
*
* Returns the event Organizer Name with a link to their single organizer page.
*
* @param int $post_id Either event id or organizer id, if none specified, current post is used.
* @param bool $full_link If true outputs a complete HTML link, otherwise only the URL is output.
* @param bool $echo Deprecated. If true, echo the link, otherwise return.
*
* @return string Organizer Name and Url
*/
function tribe_get_organizer_link( $post_id = null, $full_link = true, $echo = false ) {
// As of TEC 4.0 this argument is deprecated.
// If needed precede the call to this function with echo.
if ( false != $echo ) {
_deprecated_argument( __FUNCTION__, '4.0', 'As of TEC 4.0 this argument is deprecated. If needed, precede the call to this function with echo' );
}
$org_id = tribe_get_organizer_id( $post_id );
if ( class_exists( 'Tribe__Events__Pro__Main' ) && get_post_status( $org_id ) == 'publish' ) {
$url = esc_url_raw( get_permalink( $org_id ) );
/**
* Filter the organizer link target attribute.
*
* @since 5.1.0
*
* @param string $target The target attribute string. Defaults to "_self".
* @param string $url The link URL.
* @param int $post_id Either event id or organizer id, if none specified, current post is used.
* @param int $org_id The organizer id.
*/
$target = apply_filters( 'tribe_get_event_organizer_link_target', '_self', $url, $post_id, $org_id );
$rel = ( '_blank' === $target ) ? 'noopener noreferrer' : '';
if ( $full_link ) {
$name = tribe_get_organizer( $org_id );
if ( empty( $url ) || empty( $name ) ) {
$link = false;
} else {
$link = sprintf(
'%s',
esc_url( $url ),
the_title_attribute(
[
'post' => $org_id,
'echo' => false,
]
),
esc_attr( $target ),
esc_attr( $rel ),
esc_html( $name )
);
}
} else {
$link = $url;
}
/**
* Filter the organizer link HTML
*
* @since 4.0
*
* @param string the link HTML.
*/
return apply_filters( 'tribe_get_organizer_link', $link, $post_id, $full_link, $url );
}
//Return Organizer Name if Pro is not Active
return tribe_get_organizer( $org_id );
}
/**
* Organizer Phone
*
* Returns the event Organizer's phone number
*
* @param int $postId Can supply either event id or organizer id, if none specified, current post is used
*
* @return string Organizer's Phone Number
*/
function tribe_get_organizer_phone( $postId = null ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$output = esc_html( tribe_get_event_meta( tribe_get_organizer_id( $postId ), '_OrganizerPhone', true ) );
return apply_filters( 'tribe_get_organizer_phone', $output );
}
/**
* Organizer website url
*
* Returns the url to the event Organizer's supplied website.
*
* @param $postId post ID for an event
*
* @return string
**/
if ( ! function_exists( 'tribe_get_organizer_website_url' ) ) { // wrapped in if function exists to maintain compatibility with community events 3.0.x. wrapper not needed after 3.1.x.
function tribe_get_organizer_website_url( $postId = null ) {
$postId = Tribe__Events__Main::postIdHelper( $postId );
$output = esc_url( esc_html( tribe_get_event_meta( tribe_get_organizer_id( $postId ), '_OrganizerWebsite', true ) ) );
return apply_filters( 'tribe_get_organizer_website_url', $output );
}
}
/**
* Organizer website link
*
* Returns the event Organizer Name with a link to their supplied website
*
* @param null|int $post_id The post ID for an event.
* @param null|string $label The text for the link.
*
* @return string
**/
function tribe_get_organizer_website_link( $post_id = null, $label = null ) {
$post_id = tribe_get_organizer_id( $post_id );
$url = tribe_get_event_meta( $post_id, '_OrganizerWebsite', true );
/**
* Filter the organizer link target attribute.
*
* @since 5.1.0
*
* @param string $target The target attribute string. Defaults to "_self".
* @param string $url The link URL.
* @param null|int $post_id post ID for the organizer.
*/
$target = apply_filters( 'tribe_get_event_organizer_link_target', '_self', $url, $post_id );
$rel = ( '_blank' === $target ) ? 'noopener noreferrer' : 'external';
/**
* Filter the organizer link label
*
* @since 5.1.0
*
* @param string the link label/text.
*/
$label = apply_filters( 'tribe_get_organizer_website_link_label', $label, $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";
}
}
$html = sprintf(
'%s',
esc_attr( esc_url( $url ) ),
esc_attr( $target ),
esc_attr( $rel ),
esc_html( $label )
);
} else {
$html = '';
}
/**
* Filter the organizer link HTML
*
* @since 3.0
*
* @param string the link HTML.
*/
return apply_filters( 'tribe_get_organizer_website_link', $html );
}
/**
* Get the link for the organizer website.
*
* @since 5.5.0
*
* @param null|int $post_id The event or organizer ID.
* @return string Formatted title for the organizer website link
*/
function tribe_events_get_organizer_website_title( $post_id = null ) {
$post_id = tribe_get_organizer_id( $post_id );
/**
* Allows customization of a organizer's website title link.
*
* @since 5.5.0
*
* @param string $title The title of the organizer's website link.
* @param int $post_id The organizer ID.
*/
return apply_filters( 'tribe_events_get_organizer_website_title', __( 'Website:', 'the-events-calendar' ), $post_id );
}
/**
* Get all the organizers
*
* @param bool $only_with_upcoming Only return organizers with upcoming events attached to them.
* @param int $posts_per_page
* @param bool $suppress_filters
* @param array $args {
* Optional. Array of Query parameters.
*
* @type int $event Only organizers linked to this event post ID.
* @type bool $has_events Only organizers that have events.
* @type bool $found_posts Return the number of found organizers.
* }
*
* @return array|int An array of organizer post objects or an integer value if `found_posts` is set to a truthy value.
*/
function tribe_get_organizers( $only_with_upcoming = false, $posts_per_page = -1, $suppress_filters = true, array $args = [] ) {
// filter out the `null` values
$args = array_diff_key( $args, array_filter( $args, 'is_null' ) );
if ( tribe_is_truthy( $only_with_upcoming ) ) {
$args['only_with_upcoming'] = true;
}
$filter_args = [
'event' => 'find_for_event',
'has_events' => 'find_with_events',
'only_with_upcoming' => 'find_with_upcoming_events',
];
foreach ( $filter_args as $filter_arg => $method ) {
if ( ! isset( $args[ $filter_arg ] ) ) {
continue;
}
if ('only_with_upcoming' !== $filter_arg) {
$found = tribe( 'tec.linked-posts.organizer' )->$method( $args[ $filter_arg ] );
} else {
$found = tribe( 'tec.linked-posts.organizer' )->find_with_upcoming_events(
$args[ $filter_arg ],
isset( $args['post_status'] ) ? $args['post_status'] : null
);
}
if ( empty( $found ) ) {
return [];
}
$args['post__in'] = ! empty( $args['post__in'] )
? array_intersect( (array) $args['post__in'], $found )
: $found;
if ( empty( $args['post__in'] ) ) {
return [];
}
}
$parsed_args = wp_parse_args(
$args,
[
'post_type' => Tribe__Events__Main::ORGANIZER_POST_TYPE,
'posts_per_page' => $posts_per_page,
'suppress_filters' => $suppress_filters,
]
);
$return_found_posts = ! empty( $args['found_posts'] );
if ( $return_found_posts ) {
$parsed_args['posts_per_page'] = 1;
$parsed_args['paged'] = 1;
}
$query = new WP_Query( $parsed_args );
if ( $return_found_posts ) {
if ( $query->have_posts() ) {
return $query->found_posts;
}
return 0;
}
return $query->have_posts() ? $query->posts : [];
}
/**
* Fetches and returns a decorated post object representing a Organizer.
*
* @since 5.3.0
*
* @param null|int|WP_Post $organizer The organizer ID or post object or `null` to use the global one.
* @param string|null $output The required return type. One of `OBJECT`, `ARRAY_A`, or `ARRAY_N`, which
* correspond to a WP_Post object, an associative array, or a numeric array,
* respectively. Defaults to `OBJECT`.
* @param string $filter Type of filter to apply. Accepts 'raw'.
* @param bool $force Whether to force a re-fetch ignoring cached results or not.
*
* @return array|mixed|void|WP_Post|null {
* The Organizer post object or array, `null` if not found.
*
* @type string $phone The organizer phone number NOT filtered, apply anti-spambot filters if required.
* @type string $website The organizer full website URL.
* @type string $email The organizer email address NOT filtered, apply anti-spambot filters if required.
* }
*/
function tribe_get_organizer_object( $organizer = null, $output = OBJECT, $filter = 'raw', $force = false ) {
/**
* Filters the organizer result before any logic applies.
*
* Returning a non `null` value here will short-circuit the function and return the value.
* Note: this value will not be cached and the caching of this value is a duty left to the filtering function.
*
* @since 5.3.0
*
* @param mixed $return The organizer object to return.
* @param mixed $organizer The organizer object to fetch.
* @param string|null $output The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
* correspond to a `WP_Post` object, an associative array, or a numeric array,
* respectively. Defaults to `OBJECT`.
* @param string $filter Type of filter to apply. Accepts 'raw'.
*/
$return = apply_filters( 'tribe_get_organizer_object_before', null, $organizer, $output, $filter );
if ( null !== $return ) {
return $return;
}
/** @var Tribe__Cache $cache */
$cache = tribe( 'cache' );
$cache_key = 'tribe_get_organizer_object_' . md5( json_encode( [ $organizer, $output, $filter ] ) );
// Try getting the memoized value.
$post = $cache[ $cache_key ];
if ( false === $post ) {
// No memoized value, build from properties.
$post = Organizer::from_post( $organizer )->to_post( $output, $filter );
/**
* Filters the organizer post object before caching it and returning it.
*
* Note: this value will be cached; as such this filter might not run on each request.
* If you need to filter the output value on each call of this function then use the `tribe_get_organizer_object_before`
* filter.
*
* @since 5.3.0
*
* @param WP_Post $post The organizer post object, decorated with a set of custom properties.
* @param string $output The output format to use.
* @param string $filter The filter, or context of the fetch.
*/
$post = apply_filters( 'tribe_get_organizer_object', $post, $output, $filter );
// Memoize the value.
$cache[ $cache_key ] = $post;
}
if ( empty( $post ) ) {
return null;
}
/**
* Filters the organizer result after the organizer has been built from the function.
*
* Note: this value will not be cached and the caching of this value is a duty left to the filtering function.
*
* @since 6.0.3.1
*
* @param WP_Post $post The organizer post object to filter and return.
* @param int|WP_Post $organizer The organizer object to fetch.
* @param string|null $output The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
* correspond to a `WP_Post` object, an associative array, or a numeric array,
* respectively. Defaults to `OBJECT`.
* @param string $filter The filter, or context of the fetch.
*/
$post = apply_filters( 'tribe_get_organiser_object_after', $post, $organizer, $output, $filter );
if ( OBJECT !== $output ) {
$post = ARRAY_A === $output ? (array) $post : array_values( (array) $post );
}
return $post;
}
PK qT[ O3 3 link.phpnu [ set_current_event_id( $event_id );
/**
* Filter the output of the link to the previous event by start date of a given event.
*
* @param string $prev_event_link The link to the previous event.
* @param int $event_id The ID of the reference event.
*/
return apply_filters( 'tribe_get_prev_event_link', tribe( 'tec.adjacent-events' )->get_prev_event_link( $anchor ), $event_id );
}
/**
* Link to Next Event (Display)
*
* Display a link to the next post by start date for the given event
*
* @param bool|string $anchor link text. Use %title% to place the post title in your string.
*
* @return void
* @see tribe_get_next_event_link()
*/
function tribe_the_next_event_link( $anchor = false ) {
echo apply_filters( 'tribe_the_next_event_link', tribe_get_next_event_link( $anchor ) );
}
/**
* Return a link to the next post by start date for the given event
*
* @param bool|string $anchor link text. Use %title% to place the post title in your string.
*
* @return string
*/
function tribe_get_next_event_link( $anchor = false ) {
$event_id = get_the_ID();
tribe( 'tec.adjacent-events' )->set_current_event_id( $event_id );
/**
* Filter the output of the link to the next event by start date of a given event.
*
* @param string $next_event_link The link to the next event.
* @param int $event_id The ID of the reference event.
*/
return apply_filters( 'tribe_get_next_event_link', tribe( 'tec.adjacent-events' )->get_next_event_link( $anchor ), $event_id );
}
/**
* Get a link to the previous events
*
* @return string
*/
function tribe_get_previous_events_link() {
$link = '';
if ( tribe_is_upcoming() && ( ! empty ( $_REQUEST['tribe_paged'] ) && $_REQUEST['tribe_paged'] > 1 ) ) {
// if we're more than one page into the future, the previous link will be in the future as well
$link = tribe_get_upcoming_link();
} else {
$link = tribe_get_past_link();
}
return apply_filters( 'tribe_get_previous_events_link', $link );
}
/**
* Get a link to the next events
*
* @return string
*/
function tribe_get_next_events_link() {
$link = '';
if ( tribe_is_past() && ( ! empty ( $_REQUEST['tribe_paged'] ) && $_REQUEST['tribe_paged'] > 1 ) ) {
// if we're more than one page into the past, the next link will be in the past as well
$link = tribe_get_past_link();
} else {
$link = tribe_get_upcoming_link();
}
return apply_filters( 'tribe_get_next_events_link', $link );
}
/**
* Link to All Events
*
* Returns a link to the events URL
*
* @param string $context Optional; defaults to 'href'. Can be 'display', in which case non-latin chars are not url-encoded.
* @return string URL
*/
function tribe_get_events_link( $context = 'href' ) {
$plugin = Tribe__Events__Main::instance();
/**
* Allows for filtering the main events link.
*
* Returns a link to the events URL
*
* @param string $link The main events link.
* @param string $context Defaults to 'href'. Can also be 'display', in which case non-latin chars are not url-encoded.
*/
return apply_filters( 'tribe_get_events_link', $plugin->getLink( 'home' ), $context );
}
/**
* Gets a view permalink.
*
* @since 5.7.0
*
* @param bool|int|null $term
*
* @return string $permalink
*/
function tribe_get_view_permalink( $slug, $term = null ) {
$permalink = tribe_events_get_url( $slug );
/**
* Provides an opportunity to modify the overall view permalink.
*
* @var string $permalink
* @var string $slug
*/
$permalink = apply_filters( 'tribe_get_view_permalink', $permalink, $slug );
/**
* Provides an opportunity to modify the specific view permalink.
*
* @var string $permalink
* @var string $slug
*/
return apply_filters( "tribe_get_{$slug}_view_permalink", $permalink, $slug );
}
/**
* Link to Grid View
*
* Returns a link to the general or category calendar grid view
*
* @param string $term Optional event category to link to.
*
* @return string URL
* @todo rename
*/
function tribe_get_gridview_link( $term = null ) {
$tribe_ecp = Tribe__Events__Main::instance();
$output = $tribe_ecp->getLink( \Tribe\Events\Views\V2\Views\Month_View::get_view_slug(), false, $term );
return apply_filters( 'tribe_get_gridview_link', $output );
}
/**
* Link to List View
*
* Returns a link to the general or category upcoming view
*
* @param int $term Optional event category ID to link to.
*
* @return string URL
*/
function tribe_get_listview_link( $term = null ) {
$tribe_ecp = Tribe__Events__Main::instance();
$output = $tribe_ecp->getLink( \Tribe\Events\Views\V2\Views\List_View::get_view_slug(), false, $term );
return apply_filters( 'tribe_get_listview_link', $output );
}
/**
* Link to List View (Past)
*
* Returns a link to the general or category past view
*
* @param int|null $term Term ID
*
* @return string URL
*/
function tribe_get_listview_past_link( $term = null ) {
$tribe_ecp = Tribe__Events__Main::instance();
$output = $tribe_ecp->getLink( 'past', false, $term );
return apply_filters( 'tribe_get_listview_past_link', $output );
}
/**
* Link to a nearby List View page
*
* Returns a link to the next/previous list view page
*
* @param string $direction 'next' or 'prev'.
* @param int|null $term Term ID.
* @param string $currently_displaying Type of listview page that is currently being displayed ('past' or 'list').
* @param int $page Current page number being displayed.
*
* @return string URL
*/
function tribe_get_listview_dir_link( $direction = 'next', $term = null, $currently_displaying = null, $page = null ) {
$link = tribe_get_listview_link( $term );
// if a page isn't passed in, attempt to fetch it from a get var
if ( ! $page ) {
$page = absint( tribe_get_request_var( 'tribe_paged', 1 ) );
}
$args = tribe_get_listview_args( $page, $direction, $currently_displaying );
$link = add_query_arg(
[
'tribe_event_display' => $args['display'],
'tribe_paged' => absint( $args['page'] ),
],
$link
);
return apply_filters( 'tribe_get_listview_dir_link', $link, $term );
}
/**
* Utility function to update the pagination and current display on the list view.
*
* @since 4.6.12
*
* @param int $page
* @param string $direction
* @param null $currently_displaying
*
* @return array
*/
function tribe_get_listview_args( $page = 1, $direction = 'next', $currently_displaying = null ) {
// if what we are currently displaying is not passed in, let's set a default and check $_GET
if ( ! $currently_displaying ) {
$currently_displaying = tribe_get_listview_display();
}
// assume we want to display what we're currently displaying (until we discover otherwise)
$display = $currently_displaying;
$list_view_slug = \Tribe\Events\Views\V2\Views\List_View::get_view_slug();
if (
( 'next' === $direction && $list_view_slug === $currently_displaying )
|| ( 'prev' === $direction && 'past' === $currently_displaying )
) {
$page++;
} elseif ( $list_view_slug === $currently_displaying && 1 === $page ) {
$display = 'past';
} elseif ( 'past' === $currently_displaying && 1 === $page ) {
$display = $list_view_slug;
} else {
$page--;
}
return [
'display' => $display,
'page' => $page,
];
}
/**
* Validates that the current view is inside of the Two allowed: list or view if not default to the list view.
*
* @since 4.6.12
*
* @return string
*/
function tribe_get_listview_display() {
$view_slug = \Tribe\Events\Views\V2\Views\List_View::get_view_slug();
$default_display = $view_slug;
$display = tribe_get_request_var( 'tribe_event_display', $default_display );
$valid_values = [ $view_slug, 'past' ];
return in_array( $display, $valid_values ) ? $display : $default_display;
}
/**
* Link to prev List View
*
* Returns a link to the previous list view page
*
* @param int|null $term Term ID
*
* @return string URL
*/
function tribe_get_listview_prev_link( $term = null ) {
$link = tribe_get_listview_dir_link( 'prev', $term );
return apply_filters( 'tribe_get_listview_prev_link', $link, $term );
}
/**
* Link to next List View
*
* Returns a link to the next list view page
*
* @param int|null $term Term ID
*
* @return string URL
*/
function tribe_get_listview_next_link( $term = null ) {
$link = tribe_get_listview_dir_link( 'next', $term );
return apply_filters( 'tribe_get_listview_next_link', $link, $term );
}
/**
* Single Event Link
*
* Get link to a single event
*
* @param WP_Post|int $post_id Optional. WP Post that this affects
* @param bool $full_link Optional. If true outputs a complete HTML link, otherwise only the URL is output
*
* @return string|bool Link to post or false if none found
*/
function tribe_get_event_link( $post_id = null, $full_link = false ) {
$post_id = Tribe__Main::post_id_helper( $post_id );
$url = Tribe__Events__Main::instance()->getLink( 'single', $post_id );
if ( '' != get_option( 'permalink_structure' ) ) {
$url = trailingslashit( $url );
}
if ( $full_link ) {
$title_args = [ 'post' => $post_id, 'echo' => false ];
$name = get_the_title( $post_id );
$attr_title = the_title_attribute( $title_args );
$link = false;
if ( ! empty( $url ) && ! empty( $name ) ) {
$link = sprintf(
'%3$s',
esc_url( $url ),
$attr_title,
$name
);
}
} else {
$link = $url;
}
/**
* Filters the permalink to events
*
* @param mixed $link The link, possibly HTML, just URL, or false
* @param int $post_id Post ID
* @param bool $full_link Whether to output full HTML link
* @param string $url The URL itself
*/
return apply_filters( 'tribe_get_event_link', $link, $post_id, $full_link, $url );
}
/**
* Event Website Link (more info)
*
* @param null|object|int $event
* @param null|string $label
*
* @return string $html
*/
function tribe_get_event_website_link( $event = null, $label = null ) {
// We won't get far without a post ID. Especially since we pass it to filters that depend on it.
$post_id = Tribe__Events__Main::postIdHelper( $event );
$url = tribe_get_event_website_url( $post_id );
/**
* Filter the target attribute for the event website link
*
* @since 5.1.0
* @since 5.5.0 Added $post_id argument
*
* @param string $target The target attribute string. Defaults to "_self".
* @param string $url The link URL.
* @param null|object|int $post_id The event the url is attached to.
*/
$target = apply_filters( 'tribe_get_event_website_link_target', '_self', $url, $post_id );
$rel = ( '_blank' === $target ) ? 'noopener noreferrer' : 'external';
if ( ! empty( $url ) ) {
$label = is_null( $label ) ? $url : $label;
/**
* Filter the website link label
*
* @since 3.0
*
* @param string the link label/text.
*/
$label = apply_filters( 'tribe_get_event_website_link_label', $label, $post_id );
$html = sprintf(
'%s',
esc_url( $url ),
esc_attr( $target ),
esc_attr( $rel ),
esc_html( $label )
);
} else {
$html = '';
}
/**
* Filter the website link HTML
*
* @since 3.0
*
* @param string the link HTML.
*/
return apply_filters( 'tribe_get_event_website_link', $html );
}
/**
* Get the link for the event website.
*
* @since 5.5.0
*
* @param null|int $post_id The event or event ID.
* @return string Formatted title for the event website link
*/
function tribe_events_get_event_website_title( $post_id = null ) {
$post_id = Tribe__Main::post_id_helper( $post_id );
/**
* Allows customization of a event's website title link.
*
* @since 5.5.0
*
* @param string $title The title of the event's website link.
* @param int $post_id The event ID.
*/
return apply_filters( 'tribe_events_get_event_website_title', __( 'Website:', 'the-events-calendar' ), $post_id );
}
/**
* Event Website URL
*
* @param null|object|int $event
*
* @return string The event's website URL
*/
function tribe_get_event_website_url( $event = null ) {
$post_id = ( is_object( $event ) && isset( $event->tribe_is_event ) && $event->tribe_is_event ) ? $event->ID : $event;
$post_id = ( ! empty( $post_id ) || empty( $GLOBALS['post'] ) ) ? $post_id : get_the_ID();
$url = tribe_get_event_meta( $post_id, '_EventURL', true );
return apply_filters( 'tribe_get_event_website_url', $url, $post_id );
}
PK qT[_B B month.phpnu [ query_vars['eventDate'] ) ) {
$date = $wp_query->query_vars['eventDate'] . '-01';
}
}
}
// Confirm the date is valid (who knows what was passed in through $_REQUEST) and revert to today if necessary
try {
new DateTime( $date );
}
catch ( Exception $e ) {
$date = $today;
}
return apply_filters( 'tribe_get_month_view_date', $date );
}
/**
* Display an html link to the previous month. Used in the month navigation.
*
* No link will be returned if the link is to a month that precedes any existing
* events.
*
* @uses tribe_get_previous_month_text()
**/
function tribe_events_the_previous_month_link() {
// $html = '« ' . $text . ' ';
echo apply_filters( 'tribe_events_the_previous_month_link', null );
}
/**
* Display an html link to the next month. Used in the month navigation.
*
* @uses tribe_get_next_month_text()
**/
function tribe_events_the_next_month_link() {
// $html = '' . $text . ' »';
echo apply_filters( 'tribe_events_the_next_month_link', null );
}
/**
* Link to Previous Month
*
* Returns a link to the previous month's events page. Used in the month view.
*
* @return string URL
*/
function tribe_get_previous_month_link() {
return apply_filters( 'tribe_get_previous_month_link', null );
}
/**
* Previous Month Text
*
* Returns a textual description of the previous month
*
* @return string Name of the previous month.
*/
function tribe_get_previous_month_text() {
return apply_filters( 'tribe_get_previous_month_text', null );
}
/**
* Link to Next Month
*
* Returns a link to the next month's events page. Used in the month view.
*
* @return string URL
*/
function tribe_get_next_month_link() {
return apply_filters( 'tribe_get_next_month_link', null );
}
/**
* Current Month Text
*
* Returns a textual description of the current month
*
* @return string Name of the current month.
*/
function tribe_get_current_month_text() {
$output = date( 'F', strtotime( tribe_get_month_view_date() ) );
return apply_filters( 'tribe_get_current_month_text', $output );
}
/**
* Next Month Text
*
* Returns a textual description of the next month
*
* @return string Name of the next month.
*/
function tribe_get_next_month_text() {
return apply_filters( 'tribe_get_next_month_text', null );
}
PK qT[ url.phpnu [ get_clean_url( add_query_arg( $query, $url ) );
}
PK qT[]? ? google-map.phpnu [ ID;
}
$locationMetaSuffixes = [ 'address', 'city', 'region', 'zip', 'country' ];
$to_encode = '';
$url = '';
foreach ( $locationMetaSuffixes as $val ) {
$metaVal = call_user_func( 'tribe_get_' . $val, $post_id );
if ( $metaVal ) {
$to_encode .= $metaVal . ' ';
}
}
if ( $to_encode ) {
$url = 'https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=' . urlencode( trim( $to_encode ) );
}
$url = apply_filters( 'tribe_events_google_map_link', $url, $post_id );
$output = esc_url( $url );
return apply_filters( 'tribe_get_map_link', $output );
}
/**
* Returns a formed HTML link to Google Maps for the given event.
*
* @category Events
*
* @param string $postId
*
* @return string A fully qualified link to https://maps.google.com/ for this event
*/
function tribe_get_map_link_html( $postId = null ) {
$map_link = esc_url( tribe_get_map_link( $postId ) );
$link = '';
if ( ! empty( $map_link ) ) {
$link = sprintf(
'%s',
$map_link,
esc_html__( 'Click to view a Google Map', 'the-events-calendar' ),
esc_html__( '+ Google Map', 'the-events-calendar' )
);
}
return apply_filters( 'tribe_get_map_link_html', $link );
}
/**
* Google Map Embed
*
* Returns an embedded google maps for an event
*
* @category Events
*
* @param string $post_id
* @param int $width
* @param int $height
* @param bool $force_load If true, then load the map even if an address is not provided.
*
* @return string An iframe pulling https://maps.google.com/ for this event
*/
function tribe_get_embedded_map( $post_id = null, $width = null, $height = null, $force_load = false ) {
return Tribe__Events__Embedded_Maps::instance()->get_map( $post_id, $width, $height, $force_load );
}
/**
* Google Map Embed Test
*
* Check if embed google map is enabled for this event (or venue ).
*
* @category Events
*
* @param int $postId Id of the post, if none specified, current post is used
*
* @return bool True if google map option is set to embed the map
*/
function tribe_embed_google_map( $postId = null ) {
$output = false;
$postId = Tribe__Events__Main::postIdHelper( $postId );
$post_type = get_post_type( $postId );
if ( tribe_get_option( 'embedGoogleMaps', true ) ) {
if ( $post_type == Tribe__Events__Main::POSTTYPE ) {
$output = tribe_is_truthy( get_post_meta( $postId, '_EventShowMap', 1 ) );
} elseif ( $post_type == Tribe__Events__Main::VENUE_POST_TYPE ) {
$output = tribe_is_truthy( get_post_meta( $postId, '_VenueShowMap', 1 ) );
}
}
return apply_filters( 'tribe_embed_google_map', $output );
}
/**
* Google Map Link Test
*
* Check if google map link is enabled for this event
*
* @category Events
*
* @param int $postId Id of the post, if none specified, current post is used
*
* @return bool True if google map link is set to display the event
*/
function tribe_show_google_map_link( $postId = null ) {
$output = false;
$postId = Tribe__Events__Main::postIdHelper( $postId );
$post_type = get_post_type( $postId );
if ( $post_type == Tribe__Events__Main::POSTTYPE ) {
$output = tribe_is_truthy( get_post_meta( $postId, '_EventShowMapLink', 1 ) );
} elseif ( $post_type == Tribe__Events__Main::VENUE_POST_TYPE ) {
$output = tribe_is_truthy( get_post_meta( $postId, '_VenueShowMapLink', 1 ) );
}
return apply_filters( 'tribe_show_google_map_link', $output );
}
/**
* Gets a full URL for a basic Google Maps embed.
* See https://developers.google.com/maps/documentation/embed/guide for more info.
*
* @since 4.6.24
*
* @param string $address_string The full address for the marker to be shown on the map (e.g. an event venue).
*/
function tribe_get_basic_gmap_embed_url( $address_string ) {
$api_key = tribe_get_option( Tribe__Events__Google__Maps_API_Key::$api_key_option_name, Tribe__Events__Google__Maps_API_Key::$default_api_key );
$embed_url_args = [
'key' => $api_key,
'q' => urlencode( $address_string ),
'zoom' => (int) tribe_get_option( 'embedGoogleMapsZoom', 15 ),
];
$embed_url = add_query_arg(
/**
* Allows filtering the URL parameters passed to the basic Google Maps embed URL via add_query_arg().
* See https://developers.google.com/maps/documentation/embed/guide for all available URL parameters.
*
* @since 4.6.24
*
* @param array $embed_url_args The URL parameters being passed to the Google Maps embed URL
*/
apply_filters( 'tribe_get_basic_gmap_embed_url_args', $embed_url_args ),
/**
* Allows filtering the root Google Maps URL used for the basic map embeds; determines what Map Mode is used.
* See https://developers.google.com/maps/documentation/embed/guide for available map modes.
*
* @since 4.6.24
*
* @param string $gmaps_embed_url The root Google Maps embed URL.
*/
apply_filters( 'tribe_get_basic_gmap_embed_url', 'https://www.google.com/maps/embed/v1/place' )
);
return $embed_url;
}PK qT[̥` date.phpnu [ _end_date_fixed ) ) {
// @todo [BTRIA-613]: remove this once we can have all day events without a start / end time.
$event_end = date_create( date( Tribe__Date_Utils::DBDATETIMEFORMAT, $event_end ) );
$event_end->modify( '+1 day' );
$event_end = $event_end->format( 'U' );
}
/*
* Note:
* events that start exactly on the EOD cutoff will count on the following day
* events that end exactly on the EOD cutoff will count on the previous day
*/
$event_is_on_date = Tribe__Date_Utils::range_coincides( $start_of_day, $end_of_day, $event_start, $event_end );
return apply_filters( 'tribe_event_is_on_date', $event_is_on_date, $date, $event );
}
}
if ( ! function_exists( 'tribe_events_timezone_choice' ) ) {
/**
* Event-specific wrapper for wp_timezone_choice().
*
* @since 4.6.5
*
* @param string $selected_zone
* @param string $locale (optional)
*
* @return string
*/
function tribe_events_timezone_choice( $selected_zone, $locale = null ) {
/**
* Opportunity to modify the timezone