From cfc62c93c48ab49da773a6b51a527718a4077dbb Mon Sep 17 00:00:00 2001 From: savvasha Date: Thu, 6 Sep 2018 19:21:38 +0300 Subject: [PATCH] 1st Commit --- modules/sportspress-event-past-meetings.php | 107 ++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 modules/sportspress-event-past-meetings.php diff --git a/modules/sportspress-event-past-meetings.php b/modules/sportspress-event-past-meetings.php new file mode 100644 index 00000000..6a4ff79f --- /dev/null +++ b/modules/sportspress-event-past-meetings.php @@ -0,0 +1,107 @@ +define_constants(); + + // Actions + + // Filters + add_filter( 'sportspress_event_templates', array( $this, 'templates' ) ); + add_filter( 'sportspress_text', array( $this, 'add_text_options' ) ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_EVENT_PAST_MEETINGS_VERSION' ) ) + define( 'SP_EVENT_PAST_MEETINGS_VERSION', '2.7.0' ); + + if ( !defined( 'SP_EVENT_PAST_MEETINGS_URL' ) ) + define( 'SP_EVENT_PAST_MEETINGS_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_EVENT_PAST_MEETINGS_DIR' ) ) + define( 'SP_EVENT_PAST_MEETINGS_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Add templates to event layout. + * + * @return array + */ + public function templates( $templates = array() ) { + $templates['past_meetings'] = array( + 'title' => __( 'Past Meetings', 'sportspress' ), + 'option' => 'sportspress_event_show_past_meetings', + 'action' => array( $this, 'output' ), + 'default' => 'yes', + ); + + return $templates; + } + + /** + * Output Past Meetings. + * + * @access public + * @return void + */ + public function output() { + // Get timelines format option + $format = get_option( 'sportspress_team_events_format', 'blocks' ); + if ( 'calendar' === $format ): + sp_get_template( 'event-calendar.php', array( 'team' => $id ) ); + elseif ( 'list' === $format ): + sp_get_template( 'event-list.php', array( + 'team' => $id, + 'league' => apply_filters( 'sp_team_events_league', 0 ), + 'season' => apply_filters( 'sp_team_events_season', 0 ), + 'title_format' => 'homeaway', + 'time_format' => 'separate', + 'columns' => array( 'event', 'time', 'results' ), + 'order' => 'DESC', + ) ); + else: + sp_get_template( 'event-fixtures-results.php', array( 'team' => $id ) ); + endif; + } + + /** + * Add text options + */ + public function add_text_options( $options = array() ) { + return array_merge( $options, array( + __( 'Past Meetings', 'sportspress' ), + ) ); + } + +} + +endif; + +new SportsPress_Event_Past_Meetings();