Abbreviate team names independently

This commit is contained in:
Brian Miyaji
2016-04-13 23:59:21 +10:00
parent 99c29a0766
commit 6ba028f2cf
11 changed files with 31 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ class SP_League_Table extends SP_Custom_Post{
$usecolumns = get_post_meta( $this->ID, 'sp_columns', true );
$adjustments = get_post_meta( $this->ID, 'sp_adjustments', true );
$select = get_post_meta( $this->ID, 'sp_select', true );
$abbreviate_teams = get_option( 'sportspress_abbreviate_teams', 'yes' ) === 'yes' ? true : false;
// Get labels from result variables
$result_labels = (array)sp_get_var_labels( 'sp_result' );
@@ -537,7 +538,7 @@ class SP_League_Table extends SP_Custom_Post{
// Add team name to row
$merged[ $team_id ] = array();
$team_data['name'] = get_the_title( $team_id );
$team_data['name'] = sp_get_team_name( $team_id, $abbreviate_teams );
foreach ( $team_data as $key => $value ):

View File

@@ -115,6 +115,7 @@ class SP_Player extends SP_Custom_Post {
$metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true );
$stats = (array)get_post_meta( $this->ID, 'sp_statistics', true );
$leagues = sp_array_value( (array)get_post_meta( $this->ID, 'sp_leagues', true ), $league_id, array() );
$abbreviate_teams = get_option( 'sportspress_abbreviate_teams', 'yes' ) === 'yes' ? true : false;
$args = array(
'post_type' => array( 'sp_performance', 'sp_statistic' ),
@@ -498,7 +499,7 @@ class SP_Player extends SP_Custom_Post {
$season_name = sp_array_value( $season_names, $season_id, ' ' );
if ( $team_id ):
$team_name = get_the_title( $team_id );
$team_name = sp_get_team_name( $team_id, $abbreviate_teams );
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false ):
$team_permalink = get_permalink( $team_id );

View File

@@ -231,7 +231,7 @@ function sp_get_logo_url( $post = 0, $size = 'icon' ) {
}
function sp_get_abbreviation( $post = 0 ) {
return get_post_meta ( $post, 'sp_abbreviation', true );
return get_post_meta( $post, 'sp_abbreviation', true );
}
function sp_get_venues( $post = 0, $ids = true ) {
@@ -286,6 +286,14 @@ function sp_short_name( $post = 0 ) {
echo sp_get_short_name( $post );
}
function sp_get_team_name( $post = 0, $short = true ) {
if ( $short ) {
return sp_get_short_name( $post );
} else {
return get_the_title( $post );
}
}
function sp_team_details( $post = 0 ) {
sp_get_template( 'team-details.php', array( 'id' => $post ) );
}

View File

@@ -268,18 +268,6 @@ 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', 'sp_position', 'sp_role' ) ) )