Created
May 27, 2020 16:09
-
-
Save tanner-west/f3490ddaaea9bb3a948e47e3b39a025d to your computer and use it in GitHub Desktop.
The Events Calendar Custom Widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Events List Widget Template | |
* This is the template for the output of the events list widget. | |
* All the items are turned on and off through the widget admin. | |
* There is currently no default styling, which is needed. | |
* | |
* This view contains the filters required to create an effective events list widget view. | |
* | |
* You can recreate an ENTIRELY new events list widget view by doing a template override, | |
* and placing a list-widget.php file in a tribe-events/widgets/ directory | |
* within your theme directory, which will override the /views/widgets/list-widget.php. | |
* | |
* You can use any or all filters included in this file or create your own filters in | |
* your functions.php. In order to modify or extend a single filter, please see our | |
* readme on templates hooks and filters (TO-DO) | |
* | |
* @version 4.5.13 | |
* @return string | |
* | |
* @package TribeEventsCalendar | |
* | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( '-1' ); | |
} | |
$events_label_plural = tribe_get_event_label_plural(); | |
$events_label_plural_lowercase = tribe_get_event_label_plural_lowercase(); | |
$posts = tribe_get_list_widget_events(); | |
$time_format = get_option( 'time_format', Tribe__Date_Utils::TIMEFORMAT ); | |
$time_range_separator = tribe_get_option( 'timeRangeSeparator', ' - ' ); | |
$start_datetime = tribe_get_start_date(); | |
// Check if any event posts are found. | |
if ( $posts ) : ?> | |
<div class="tribe-list-widget row"> | |
<?php | |
// Setup the post data for each event. | |
foreach ( $posts as $post ) : | |
setup_postdata( $post ); | |
?> | |
<div class="tribe-events-list-widget-events col-12 <?php tribe_events_event_classes() ?>"> | |
<div class="cc-event-list-widget-date-container"> | |
<?php do_action( 'tribe_events_list_widget_before_the_meta' ) ?> | |
<?php | |
$event_date = tribe_get_start_date( $post, false, 'd' ); | |
$event_month = tribe_get_start_date( $post, false, 'M' ); | |
$start_time = tribe_get_start_date( $post, false, $time_format ); | |
$end_time = tribe_get_end_date( $post, false, $time_format ); | |
?> | |
<span class="cc-event-list-widget-date"><?php echo $event_date; ?></span> | |
<span class="cc-event-list-widget-month"><?php echo $event_month; ?></span> | |
<?php do_action( 'tribe_events_list_widget_after_the_meta' ) ?> | |
</div> | |
<div class="cc-event-list-widget-info-container"> | |
<?php do_action( 'tribe_events_list_widget_before_the_event_title' ); ?> | |
<!-- Event Title --> | |
<h4 class="tribe-event-title"> | |
<a href="<?php echo esc_url( tribe_get_event_link() ); ?>" rel="bookmark"><?php the_title(); ?></a> | |
</h4> | |
<span class="cc-event-list-widget-start-time"><?php echo $start_time; ?></span> | |
<?php do_action( 'tribe_events_list_widget_after_the_event_title' ); ?> | |
<a href="<?php echo esc_url( tribe_get_event_link() ); ?>" rel="bookmark"> | |
<span>Learn More</span> | |
</a> | |
</div> | |
</div> | |
<?php | |
endforeach; | |
?> | |
</div><!-- .tribe-list-widget --> | |
<p class="tribe-events-widget-link"> | |
<a href="<?php echo esc_url( tribe_get_events_link() ); ?>" rel="bookmark"><?php printf( esc_html__( 'View All %s', 'the-events-calendar' ), $events_label_plural ); ?></a> | |
</p> | |
<?php | |
// No events were found. | |
else : ?> | |
<p><?php printf( esc_html__( 'There are no upcoming %s at this time.', 'the-events-calendar' ), $events_label_plural_lowercase ); ?></p> | |
<?php | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment