| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Returns a URL of the national flag icon. |
| 5 |
* |
| 6 |
* @deprecated 3.7 |
| 7 |
*/ |
| 8 |
function bogo_get_flag( $locale ) { |
| 9 |
if ( WP_DEBUG ) { |
| 10 |
wp_trigger_error( |
| 11 |
__FUNCTION__, |
| 12 |
sprintf( |
| 13 |
/* translators: 1: PHP function name, 2: version number */ |
| 14 |
__( 'Function %1$s is <strong>deprecated</strong> since Bogo version %2$s with no alternative available.', 'bogo' ), |
| 15 |
__FUNCTION__, |
| 16 |
'3.7' |
| 17 |
), |
| 18 |
E_USER_DEPRECATED |
| 19 |
); |
| 20 |
} |
| 21 |
|
| 22 |
$locale = explode( '_', $locale ); |
| 23 |
$locale = array_slice( $locale, 0, 2 ); // de_DE_formal => de_DE |
| 24 |
$locale = implode( '_', $locale ); |
| 25 |
|
| 26 |
$special_cases = array( |
| 27 |
'ca' => 'catalonia', |
| 28 |
'gd' => 'scotland', |
| 29 |
'cy' => 'wales', |
| 30 |
'am' => 'et', |
| 31 |
'az' => 'az', |
| 32 |
'bel' => 'by', |
| 33 |
'bs' => 'ba', |
| 34 |
'dzo' => 'bt', |
| 35 |
'el' => 'gr', |
| 36 |
'et' => 'ee', |
| 37 |
'fi' => 'fi', |
| 38 |
'ga' => 'ie', |
| 39 |
'hr' => 'hr', |
| 40 |
'ht' => 'ht', |
| 41 |
'hy' => 'am', |
| 42 |
'ja' => 'jp', |
| 43 |
'kk' => 'kz', |
| 44 |
'km' => 'kh', |
| 45 |
'lo' => 'la', |
| 46 |
'lv' => 'lv', |
| 47 |
'mn' => 'mn', |
| 48 |
'sq' => 'al', |
| 49 |
'tg' => 'tj', |
| 50 |
'th' => 'th', |
| 51 |
'tl' => 'ph', |
| 52 |
'uk' => 'ua', |
| 53 |
'vi' => 'vn', |
| 54 |
); |
| 55 |
|
| 56 |
if ( isset( $special_cases[$locale] ) ) { |
| 57 |
$file = $special_cases[$locale] . '.png'; |
| 58 |
} elseif ( preg_match( '/_([A-Z]{2})$/', $locale, $matches ) ) { |
| 59 |
$file = strtolower( $matches[1] ) . '.png'; |
| 60 |
} else { |
| 61 |
$file = 'zz.png'; // 'zz.png' doesn't exist, just a dummy. |
| 62 |
} |
| 63 |
|
| 64 |
$file = path_join( 'images/flag-icons', $file ); |
| 65 |
$url = ''; |
| 66 |
|
| 67 |
if ( file_exists( path_join( BOGO_PLUGIN_DIR, $file ) ) ) { |
| 68 |
$url = bogo_plugin_url( $file ); |
| 69 |
} |
| 70 |
|
| 71 |
return apply_filters( 'bogo_get_flag', $url, $locale ); |
| 72 |
} |
| 73 |
|