| @@ -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', |
| @@ -66,17 +65,16 @@ | ||
| 66 | 65 | if ( isset( $special_cases[$locale] ) ) { |
| 67 | 66 | $file = $special_cases[$locale] . '.png'; |
| 68 | 67 | } elseif ( preg_match( '/_([A-Z]{2})$/', $locale, $matches ) ) { |
| 69 | 68 | $file = strtolower( $matches[1] ) . '.png'; |
| 70 | - } else { | |
| 71 | - $file = 'zz.png'; // 'zz.png' doesn't exist, just a dummy. | |
| 72 | 69 | } |
| 73 | 70 | |
| 74 | - $file = path_join( 'images/flag-icons', $file ); | |
| 75 | 71 | $url = ''; |
| 76 | 72 | |
| 77 | - if ( file_exists( path_join( BOGO_PLUGIN_DIR, $file ) ) ) { | |
| 78 | - $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 ); | |
| 79 | 75 | } |
| 80 | 76 | |
| 81 | 77 | return apply_filters( 'bogo_get_flag', $url, $locale ); |
| 82 | 78 | } |
| 79 | + | |
| 80 | +?> | |