PluginProbe
Bogo / 2.6
Bogo v2.6
3.9.3 trunk 1.0 1.1 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.8 2.8.1 2.9 3.0 3.0.1 All 52 releases
← All changes | includes/flags.php +32 -22 trunk2.6 View file →
@@ -1,25 +1,39 @@
1 1 <?php
2 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 - );
3 +add_action( 'wp_head', 'bogo_flag_css' );
4 +
5 +function bogo_flag_css() {
6 + $flags = array();
7 +
8 + if ( apply_filters( 'bogo_use_flags', true ) ) {
9 + $locales = bogo_available_locales();
10 +
11 + foreach ( $locales as $locale ) {
12 + if ( $flag = bogo_get_flag( $locale ) ) {
13 + $flags[$locale] = $flag;
14 + }
15 + }
20 16 }
21 17
18 + if ( ! $flags ) {
19 + return;
20 + }
21 +
22 + $side = is_rtl() ? 'right' : 'left';
23 +
24 + echo '<style type="text/css">' . "\n";
25 +
26 + foreach ( $flags as $locale => $flag ) {
27 + echo '.bogo-language-switcher .' . bogo_language_tag( $locale ) . ' {';
28 + echo ' background: url("' . $flag . '") no-repeat ' . $side . ' center;';
29 + echo ' }' . "\n";
30 + }
31 +
32 + echo '</style>' . "\n";
33 +}
34 +
35 +function bogo_get_flag( $locale ) {
22 36 $locale = explode( '_', $locale );
23 37 $locale = array_slice( $locale, 0, 2 ); // de_DE_formal => de_DE
24 38 $locale = implode( '_', $locale );
25 39
@@ -28,11 +42,9 @@
28 42 'gd' => 'scotland',
29 43 'cy' => 'wales',
30 44 'am' => 'et',
31 45 'az' => 'az',
32 - 'bel' => 'by',
33 46 'bs' => 'ba',
34 - 'dzo' => 'bt',
35 47 'el' => 'gr',
36 48 'et' => 'ee',
37 49 'fi' => 'fi',
38 50 'ga' => 'ie',
@@ -40,9 +52,8 @@
40 52 'ht' => 'ht',
41 53 'hy' => 'am',
42 54 'ja' => 'jp',
43 55 'kk' => 'kz',
44 - 'km' => 'kh',
45 56 'lo' => 'la',
46 57 'lv' => 'lv',
47 58 'mn' => 'mn',
48 59 'sq' => 'al',
@@ -49,10 +60,9 @@
49 60 'tg' => 'tj',
50 61 'th' => 'th',
51 62 'tl' => 'ph',
52 63 'uk' => 'ua',
53 - 'vi' => 'vn',
54 - );
64 + 'vi' => 'vn' );
55 65
56 66 if ( isset( $special_cases[$locale] ) ) {
57 67 $file = $special_cases[$locale] . '.png';
58 68 } elseif ( preg_match( '/_([A-Z]{2})$/', $locale, $matches ) ) {