From e24cd547e2902d41eed3140e2428e8aebfb0dc03 Mon Sep 17 00:00:00 2001
From: Brian Miyaji
' . __( 'Date', 'sportspress' ). ' ';
- if ( in_array( 'event', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
$output .= '' . __( 'Event', 'sportspress' ). ' ';
- if ( in_array( 'teams', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
$output .= '' . __( 'Teams', 'sportspress' ). ' ';
- if ( in_array( 'time', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
$output .= '' . __( 'Time', 'sportspress' ). ' ';
- if ( in_array( 'article', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
$output .= '' . __( 'Article', 'sportspress' ). ' ';
$output .= '' . '' . '';
@@ -44,10 +45,10 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
$output .= '' . get_post_time( get_option( 'date_format' ), false, $event ) . ' ';
- if ( in_array( 'event', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
$output .= '' . $event->post_title . ' ';
- if ( in_array( 'teams', $usecolumns ) ):
+ if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
$output .= '';
$teams = get_post_meta( $event->ID, 'sp_team', false );
@@ -84,10 +85,10 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
$output .= ' ';
endif;
- if ( in_array( 'time', $usecolumns ) )
+ if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
$output .= '' . get_post_time( get_option( 'time_format' ), false, $event ) . ' ';
- if ( in_array( 'article', $usecolumns ) ):
+ if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
$output .= '
';
@@ -113,7 +114,12 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
$i++;
endforeach;
- $output .= ' ' . '' . '';
+ $output .= '' . '';
+
+ if ( $id && $r['show_all_events_link'] )
+ $output .= '' . __( 'View all events', 'sportspress' ) . '';
+
+ $output .= '';
return apply_filters( 'sportspress_events_list', $output );
diff --git a/admin/widgets/events-calendar.php b/admin/widgets/events-calendar.php
index de44dc55..df301fcd 100644
--- a/admin/widgets/events-calendar.php
+++ b/admin/widgets/events-calendar.php
@@ -10,11 +10,12 @@ class SportsPress_Widget_Events_Calendar extends WP_Widget {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$id = empty($instance['id']) ? null : $instance['id'];
+ $show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '
> +
'widget_sp_events_list', 'description' => __( 'A list of events.', 'sportspress' ) ); + parent::__construct('sp_events_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); + $id = empty($instance['id']) ? null : $instance['id']; + $columns = empty($instance['columns']) ? null : $instance['columns']; + $show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link']; + echo $before_widget; + if ( $title ) + echo $before_title . $title . $after_title; + echo sportspress_events_list( $id, array( 'columns' => $columns, 'show_all_events_link' => $show_all_events_link ) ); + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['id'] = intval($new_instance['id']); + $instance['columns'] = (array)$new_instance['columns']; + $instance['show_all_events_link'] = $new_instance['show_all_events_link']; + + return $instance; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'columns' => null, 'show_all_events_link' => true ) ); + $title = strip_tags($instance['title']); + $id = intval($instance['id']); + $columns = $instance['columns']; + $show_all_events_link = $instance['show_all_events_link']; +?> ++
+ ++ 'sp_calendar', + 'show_option_all' => __( 'All', 'sportspress' ), + 'name' => $this->get_field_name('id'), + 'id' => $this->get_field_id('id'), + 'selected' => $id, + 'values' => 'ID', + 'class' => 'sp-events-calendar-select widefat', + ); + if ( ! sportspress_dropdown_pages( $args ) ): + sportspress_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) ); + endif; + ?> +
+ +
+
+ __( 'Event', 'sportspress' ),
+ 'teams' => __( 'Teams', 'sportspress' ),
+ 'time' => __( 'Time', 'sportspress' ),
+ 'article' => __( 'Article', 'sportspress' ),
+ );
+ $field_name = $this->get_field_name('columns') . '[]';
+ $field_id = $this->get_field_id('columns');
+ ?>
+ $label ): ?>
+
+
+
> +
+ 'sp_event', @@ -1513,49 +1508,59 @@ if ( !function_exists( 'sportspress_get_calendar_data' ) ) { ), ); - if ( $leagues ): - $league_ids = array(); - foreach( $leagues as $league ): - $league_ids[] = $league->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_league', - 'field' => 'id', - 'terms' => $league_ids - ); - endif; + if ( $post_id ): + $leagues = get_the_terms( $post_id, 'sp_league' ); + $seasons = get_the_terms( $post_id, 'sp_season' ); + $venues = get_the_terms( $post_id, 'sp_venue' ); + $team = get_post_meta( $post_id, 'sp_team', true ); + $usecolumns = get_post_meta( $post_id, 'sp_columns', true ); - if ( $seasons ): - $season_ids = array(); - foreach( $seasons as $season ): - $season_ids[] = $season->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_season', - 'field' => 'id', - 'terms' => $season_ids - ); - endif; + if ( $leagues ): + $league_ids = array(); + foreach( $leagues as $league ): + $league_ids[] = $league->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_league', + 'field' => 'id', + 'terms' => $league_ids + ); + endif; - if ( $venues ): - $venue_ids = array(); - foreach( $venues as $venue ): - $venue_ids[] = $venue->term_id; - endforeach; - $args['tax_query'][] = array( - 'taxonomy' => 'sp_venue', - 'field' => 'id', - 'terms' => $venue_ids - ); - endif; + if ( $seasons ): + $season_ids = array(); + foreach( $seasons as $season ): + $season_ids[] = $season->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_season', + 'field' => 'id', + 'terms' => $season_ids + ); + endif; - if ( $team ): - $args['meta_query'] = array( - array( - 'key' => 'sp_team', - 'value' => $team, - ), - ); + if ( $venues ): + $venue_ids = array(); + foreach( $venues as $venue ): + $venue_ids[] = $venue->term_id; + endforeach; + $args['tax_query'][] = array( + 'taxonomy' => 'sp_venue', + 'field' => 'id', + 'terms' => $venue_ids + ); + endif; + + if ( $team ): + $args['meta_query'] = array( + array( + 'key' => 'sp_team', + 'value' => $team, + ), + ); + endif; + else: + $usecolumns = null; endif; $events = get_posts( $args ); diff --git a/sportspress.php b/sportspress.php index eb1c98e9..80f04852 100644 --- a/sportspress.php +++ b/sportspress.php @@ -85,6 +85,7 @@ require_once dirname( __FILE__ ) . '/admin/terms/position.php'; // Widgets require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php'; require_once dirname( __FILE__ ) . '/admin/widgets/events-calendar.php'; +require_once dirname( __FILE__ ) . '/admin/widgets/events-list.php'; require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php'; require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php';