| @@ -32,11 +32,10 @@ | ||
| 32 | 32 | echo '</style>' . "\n"; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function bogo_get_flag( $locale ) { |
| 36 | - $locale = explode( '_', $locale ); | |
| 37 | - $locale = array_slice( $locale, 0, 2 ); // de_DE_formal => de_DE | |
| 38 | - $locale = implode( '_', $locale ); | |
| 36 | + $dir = '/images/flag-icons'; | |
| 37 | + $file = ''; | |
| 39 | 38 | |
| 40 | 39 | $special_cases = array( |
| 41 | 40 | 'ca' => 'catalonia', |
| 42 | 41 | 'gd' => 'scotland', |
| @@ -52,9 +51,8 @@ | ||
| 52 | 51 | 'ht' => 'ht', |
| 53 | 52 | 'hy' => 'am', |
| 54 | 53 | 'ja' => 'jp', |
| 55 | 54 | 'kk' => 'kz', |
| 56 | - 'km' => 'kh', | |
| 57 | 55 | 'lo' => 'la', |
| 58 | 56 | 'lv' => 'lv', |
| 59 | 57 | 'mn' => 'mn', |
| 60 | 58 | 'sq' => 'al', |
| @@ -67,17 +65,16 @@ | ||
| 67 | 65 | if ( isset( $special_cases[$locale] ) ) { |
| 68 | 66 | $file = $special_cases[$locale] . '.png'; |
| 69 | 67 | } elseif ( preg_match( '/_([A-Z]{2})$/', $locale, $matches ) ) { |
| 70 | 68 | $file = strtolower( $matches[1] ) . '.png'; |
| 71 | - } else { | |
| 72 | - $file = 'zz.png'; // 'zz.png' doesn't exist, just a dummy. | |
| 73 | 69 | } |
| 74 | 70 | |
| 75 | - $file = path_join( 'images/flag-icons', $file ); | |
| 76 | 71 | $url = ''; |
| 77 | 72 | |
| 78 | - if ( file_exists( path_join( BOGO_PLUGIN_DIR, $file ) ) ) { | |
| 79 | - $url = bogo_plugin_url( $file ); | |
| 73 | + if ( $file && file_exists( path_join( BOGO_PLUGIN_DIR . $dir, $file ) ) ) { | |
| 74 | + $url = path_join( BOGO_PLUGIN_URL . $dir, $file ); | |
| 80 | 75 | } |
| 81 | 76 | |
| 82 | 77 | return apply_filters( 'bogo_get_flag', $url, $locale ); |
| 83 | 78 | } |
| 79 | + | |
| 80 | +?> | |