Add events list widget and close #6

This commit is contained in:
Brian Miyaji
2014-03-17 22:29:10 +11:00
parent fd7588d7dc
commit e24cd547e2
8 changed files with 178 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
<?php
if ( !function_exists( 'sportspress_events_calendar' ) ) {
function sportspress_events_calendar( $id = null, $single = false, $initial = true ) {
function sportspress_events_calendar( $id = null, $initial = true, $args = array() ) {
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
@@ -8,6 +8,13 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
if ( ! $posts )
return;
$defaults = array(
'caption_tag' => 'caption',
'show_all_events_link' => false,
);
$r = wp_parse_args( $args, $defaults );
if ( $id ):
$events = sportspress_get_calendar_data( $id );
$event_ids = array();
@@ -19,7 +26,7 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
$in = '';
endif;
$caption_tag = ( $single ? 'h4' : 'caption' );
$caption_tag = $r['caption_tag'];
// week_begins = 0 stands for Sunday
$week_begins = intval(get_option('start_of_week'));
@@ -189,6 +196,9 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
if ( $id && $r['show_all_events_link'] )
$calendar_output .= '<a class="sp-all-events-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
return apply_filters( 'sportspress_events_calendar', $calendar_output );
}