From 183ce65dda0f5de665c23e62f8c779d890152b72 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 21 Oct 2014 02:28:59 +1100 Subject: [PATCH] Display event team logos via template --- assets/css/sportspress.css | 3 ++- includes/sp-template-functions.php | 14 ++++++++++++++ includes/sp-template-hooks.php | 29 +++++++++++++---------------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index 9fccfe3a..e18585e5 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -7,9 +7,10 @@ } /* Title */ -.sp-event-teams { +.sp-event-logos { margin-top: 0.5em; margin-bottom: 0.5em; + text-align: center; } /* Data Tables */ diff --git a/includes/sp-template-functions.php b/includes/sp-template-functions.php index d572c368..465e59f1 100644 --- a/includes/sp-template-functions.php +++ b/includes/sp-template-functions.php @@ -70,6 +70,20 @@ if ( ! function_exists( 'sportspress_taxonomy_archive_description' ) ) { /** Single Event ********************************************************/ +if ( ! function_exists( 'sportspress_output_event_logos' ) ) { + + /** + * Output the event logos. + * + * @access public + * @subpackage Event/Logos + * @return void + */ + function sportspress_output_event_logos() { + sp_get_template( 'event-logos.php' ); + } +} + if ( ! function_exists( 'sportspress_output_event_video' ) ) { /** diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index a381382c..e4c013ee 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -31,6 +31,7 @@ add_action( 'get_the_generator_xhtml', 'sp_generator_tag', 10, 2 ); * @see sportspress_output_event_venue() * @see sportspress_output_event_performance() */ +add_action( 'sportspress_single_event_content', 'sportspress_output_event_logos', 5 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_video', 10 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_results', 20 ); add_action( 'sportspress_single_event_content', 'sportspress_output_event_details', 30 ); @@ -119,22 +120,6 @@ function sportspress_the_title( $title, $id = null ) { if ( $role ): $title = '' . $role->name . ' ' . $title; endif; - elseif ( is_singular( 'sp_event' ) && get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ): - $teams = get_post_meta( $id, 'sp_team' ); - $teams = array_filter( $teams ); - if ( $teams ): - $team_logos = array(); - foreach ( $teams as $team ): - $team_logos[] = get_the_post_thumbnail( $team, 'sportspress-fit-icon' ); - endforeach; - $team_logos = array_filter( $team_logos ); - if ( ! empty( $team_logos ) ): - $title .= '
'; - $delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' ); - $title .= implode( ' ' . $delimiter . ' ', $team_logos ); - $title .= '
'; - endif; - endif; endif; endif; @@ -252,6 +237,18 @@ function sportspress_team_permalink( $permalink, $post ) { } add_filter( 'post_type_link', 'sportspress_team_permalink', 10, 2 ); +function sportspress_abbreviate_team( $title, $id = null ) { + if ( ! is_admin() && 'sp_team' == get_post_type( $id ) && get_option( 'sportspress_abbreviate_teams', 'yes' ) == 'yes' ): + if ( in_the_loop() && get_the_ID() == $id ) return $title; + $abbreviation = get_post_meta( $id, 'sp_abbreviation', true ); + if ( ! empty( $abbreviation ) ): + return $abbreviation; + endif; + endif; + return $title; +} +add_filter( 'the_title', 'sportspress_abbreviate_team', 10, 2 ); + function sportspress_no_terms_links( $term_list, $taxonomy ) { if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) )