From e71f3e3fef3c148d1bd31d0e53a216353b35e9e6 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 4 May 2018 09:42:44 +1000 Subject: [PATCH] Fix non-alphanumeric abbreviations --- .../post-types/meta-boxes/class-sp-meta-box-outcome-details.php | 2 +- includes/class-sp-player.php | 2 +- includes/class-sp-team.php | 2 +- includes/sp-api-functions.php | 2 +- includes/sp-core-functions.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php index 4bc24b63..1183805c 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php @@ -45,7 +45,7 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {

- +

diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php index 58f1b421..99082754 100644 --- a/includes/class-sp-player.php +++ b/includes/class-sp-player.php @@ -505,7 +505,7 @@ class SP_Player extends SP_Custom_Post { if ( $outcomes ): $outcome = reset( $outcomes ); $abbreviation = sp_get_abbreviation( $outcome->ID ); - if ( empty( $abbreviation ) ) $abbreviation = strtoupper( substr( $outcome->post_title, 0, 1 ) ); + if ( empty( $abbreviation ) ) $abbreviation = mb_strtoupper( mb_substr( $outcome->post_title, 0, 1 ) ); $totals['streak'] = $abbreviation . $streak['count']; endif; diff --git a/includes/class-sp-team.php b/includes/class-sp-team.php index ff30bd86..e429b111 100644 --- a/includes/class-sp-team.php +++ b/includes/class-sp-team.php @@ -323,7 +323,7 @@ class SP_Team extends SP_Custom_Post { $outcome = reset( $outcomes ); $abbreviation = get_post_meta( $outcome->ID, 'sp_abbreviation', true ); if ( ! $abbreviation ) - $abbreviation = substr( $outcome->post_title, 0, 1 ); + $abbreviation = mb_substr( $outcome->post_title, 0, 1 ); $totals['streak'] = $abbreviation . $streak['count']; endif; diff --git a/includes/sp-api-functions.php b/includes/sp-api-functions.php index 5b8283c5..89b4ab62 100644 --- a/includes/sp-api-functions.php +++ b/includes/sp-api-functions.php @@ -296,7 +296,7 @@ function sp_team_abbreviation( $post = 0, $forced = false ) { if ( $abbreviation ) { return $abbreviation; } else { - return $forced ? substr( strtoupper( sp_team_short_name( $post ) ), 0, 3 ) : sp_team_short_name( $post ); + return $forced ? mb_substr( mb_strtoupper( sp_team_short_name( $post ) ), 0, 3 ) : sp_team_short_name( $post ); } } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 6f02de81..e8d9828a 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -418,7 +418,7 @@ if ( !function_exists( 'sp_get_post_abbreviation' ) ) { if ( $abbreviation ): return $abbreviation; else: - return substr( get_the_title( $post_id ), 0, 1 ); + return mb_substr( get_the_title( $post_id ), 0, 1 ); endif; } }