Merge pull request #407 from ThemeBoy/feature-new-flags

New flags
This commit is contained in:
Brian Miyaji
2021-05-25 15:25:30 +09:00
committed by GitHub
13 changed files with 37 additions and 4 deletions

BIN
assets/images/flags/glp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

BIN
assets/images/flags/grl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/flags/guf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

BIN
assets/images/flags/mtq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
assets/images/flags/pyf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/images/flags/reu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

BIN
assets/images/flags/sxm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -68,6 +68,7 @@ class SP_Countries {
'nam',
'nga',
'nig',
'reu',
'rsa',
'rwa',
'sdn',
@@ -207,6 +208,8 @@ class SP_Countries {
'cuw',
'dma',
'dom',
'glp',
'grl',
'grn',
'gua',
'hai',
@@ -214,12 +217,14 @@ class SP_Countries {
'jam',
'lca',
'mex',
'mtq',
'msr',
'nca',
'pan',
'pur',
'skn',
'slv',
'sxm',
'tca',
'usa',
'vgb',
@@ -242,6 +247,7 @@ class SP_Countries {
'nzl',
'plw',
'png',
'pyf',
'sam',
'sol',
'tah',
@@ -257,6 +263,7 @@ class SP_Countries {
'chi',
'col',
'ecu',
'guf',
'guy',
'par',
'per',
@@ -338,6 +345,8 @@ class SP_Countries {
'fin' => __( "Finland", 'sportspress' ),
'fra' => __( "France", 'sportspress' ),
'fro' => __( "Faroe Islands", 'sportspress' ),
'guf' => __( "French Guiana", 'sportspress' ),
'pyf' => __( "French Polynesia", 'sportspress' ),
'fsm' => __( "Micronesia", 'sportspress' ),
'gab' => __( "Gabon", 'sportspress' ),
'gam' => __( "Gambia", 'sportspress' ),
@@ -346,8 +355,10 @@ class SP_Countries {
'ger' => __( "Germany", 'sportspress' ),
'gha' => __( "Ghana", 'sportspress' ),
'gib' => __( "Gibraltar", 'sportspress' ),
'glp' => __( "Guadeloupe", 'sportspress' ),
'gnb' => __( "Guinea-Bissau", 'sportspress' ),
'gre' => __( "Greece", 'sportspress' ),
'grl' => __( "Greenland", 'sportspress' ),
'grn' => __( "Grenada", 'sportspress' ),
'gua' => __( "Guatemala", 'sportspress' ),
'gui' => __( "Guinea", 'sportspress' ),
@@ -373,6 +384,7 @@ class SP_Countries {
'kos' => __( "Kosovo", 'sportspress' ),
'kgz' => __( "Kyrgyzstan", 'sportspress' ),
'kir' => __( "Kiribati", 'sportspress' ),
'mtq' => __( "Martinique", 'sportspress' ),
'kor' => __( "South Korea", 'sportspress' ),
'ksa' => __( "Saudi Arabia", 'sportspress' ),
'kuw' => __( "Kuwait", 'sportspress' ),
@@ -433,6 +445,7 @@ class SP_Countries {
'qat' => __( "Qatar", 'sportspress' ),
'rou' => __( "Romania", 'sportspress' ),
'rsa' => __( "South Africa", 'sportspress' ),
'reu' => __( "Reunion", 'sportspress' ),
'rus' => __( "Russia", 'sportspress' ),
'rwa' => __( "Rwanda", 'sportspress' ),
'sam' => __( "Samoa", 'sportspress' ),
@@ -457,6 +470,7 @@ class SP_Countries {
'svn' => __( "Slovenia", 'sportspress' ),
'swe' => __( "Sweden", 'sportspress' ),
'swz' => __( "Eswatini", 'sportspress' ),
'sxm' => __( "Sint Maarten", 'sportspress' ),
'syr' => __( "Syria", 'sportspress' ),
'tah' => __( "Tahiti", 'sportspress' ),
'tan' => __( "Tanzania", 'sportspress' ),

View File

@@ -1715,3 +1715,22 @@ function sp_has_shortcodes( $content, $tags ) {
}
return false;
}
/**
* Check if a custom flag was uploaded from the user
* @return bool
*/
function sp_flags( $nationality ) {
$nationality = strtolower( $nationality );
$flag = '';
global $wpdb;
$flag_post_id = intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$nationality'" ) );
if ( $flag_post_id ) {
$flag_src = wp_get_attachment_image_url( $flag_post_id, array( 23,15), false );
$flag = '<img src="' . $flag_src . '" alt="' . $nationality . '">';
}else{
$flag = '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . $nationality . '.png" alt="' . $nationality . '">';
}
return $flag;
}

View File

@@ -51,7 +51,7 @@ if ( $show_nationality ):
$values = array();
foreach ( $nationalities as $nationality ):
$country_name = sp_array_value( $countries, $nationality, null );
$values[] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '&mdash;';
$values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '&mdash;';
endforeach;
$common[ __( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
endif;

View File

@@ -51,7 +51,7 @@ if ( $show_nationality ):
$values = array();
foreach ( $nationalities as $nationality ):
$country_name = sp_array_value( $countries, $nationality, null );
$values[] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '&mdash;';
$values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '&mdash;';
endforeach;
$common[ __( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
endif;

View File

@@ -179,7 +179,7 @@ foreach ( $groups as $group ):
$nationalities = $player->nationalities();
if ( ! empty( $nationalities ) ):
foreach ( $nationalities as $nationality ):
$name = '<span class="player-flag"><img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"></span>' . $name;
$name = '<span class="player-flag">' . sp_flags( $nationality ) . '</span>' . $name;
endforeach;
$name_class .= ' has-photo';
endif;

View File

@@ -41,7 +41,7 @@ if ( $show_nationality && $nationalities && is_array( $nationalities ) ):
$nationality = sp_array_value( $legacy, $nationality, null );
endif;
$country_name = sp_array_value( $countries, $nationality, null );
$values[] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '&mdash;';
$values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '&mdash;';
endforeach;
$data[ __( 'Nationality', 'sportspress' ) ] = implode( '<br>', $values );
endif;