PluginProbe
Bogo / 2.9
Bogo v2.9
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/user.php +24 -8 2.4.32.9 View file →
@@ -7,18 +7,22 @@
7 7 function bogo_admin_bar_menu( $wp_admin_bar ) {
8 8 $current_locale = bogo_get_user_locale();
9 9 $current_language = bogo_get_language( $current_locale );
10 10
11 - if ( ! $current_language )
11 + if ( ! $current_language ) {
12 12 $current_language = $current_locale;
13 + }
13 14
14 15 $wp_admin_bar->add_menu( array(
15 16 'parent' => 'top-secondary',
16 17 'id' => 'bogo-user-locale',
17 - 'title' => '✔ ' . $current_language ) );
18 + 'title' => sprintf(
19 + '<span class="ab-icon"></span><span class="ab-label">%s</span>',
20 + esc_html( $current_language ) ) ) );
18 21
19 22 $available_languages = bogo_available_languages( array(
20 23 'exclude' => array( $current_locale ),
24 + 'exclude_enus_if_inactive' => true,
21 25 'current_user_can_access' => true ) );
22 26
23 27 foreach ( $available_languages as $locale => $lang ) {
24 28 $url = admin_url( 'profile.php?action=bogo-switch-locale&locale=' . $locale );
@@ -39,17 +43,21 @@
39 43
40 44 add_action( 'admin_init', 'bogo_switch_user_locale' );
41 45
42 46 function bogo_switch_user_locale() {
43 - if ( empty( $_REQUEST['action'] ) || 'bogo-switch-locale' != $_REQUEST['action'] )
47 + if ( empty( $_REQUEST['action'] )
48 + || 'bogo-switch-locale' != $_REQUEST['action'] ) {
44 49 return;
50 + }
45 51
46 52 check_admin_referer( 'bogo-switch-locale' );
47 53
48 54 $locale = isset( $_REQUEST['locale'] ) ? $_REQUEST['locale'] : '';
49 55
50 - if ( ! bogo_is_available_locale( $locale ) || $locale == bogo_get_user_locale() )
56 + if ( ! bogo_is_available_locale( $locale )
57 + || $locale == bogo_get_user_locale() ) {
51 58 return;
59 + }
52 60
53 61 update_user_option( get_current_user_id(), 'locale', $locale, true );
54 62
55 63 if ( ! empty( $_REQUEST['redirect_to'] ) ) {
@@ -74,8 +82,9 @@
74 82
75 83 $locale = get_user_option( 'locale', $user_id );
76 84
77 85 if ( bogo_is_available_locale( $locale )
86 + && ( 'en_US' != $locale || ! bogo_get_prop( 'enus_deactivated' ) )
78 87 && user_can( $user_id, 'bogo_access_locale', $locale ) ) {
79 88 return $locale;
80 89 }
81 90
@@ -82,9 +91,12 @@
82 91 if ( user_can( $user_id, 'bogo_access_locale', $default_locale ) ) {
83 92 return $default_locale;
84 93 }
85 94
86 - foreach ( (array) bogo_available_locales() as $locale ) {
95 + $available_locales = bogo_available_locales( array(
96 + 'exclude_enus_if_inactive' => true ) );
97 +
98 + foreach ( $available_locales as $locale ) {
87 99 if ( user_can( $user_id, 'bogo_access_locale', $locale ) ) {
88 100 return $locale;
89 101 }
90 102 }
@@ -97,8 +109,12 @@
97 109
98 110 $user_id = absint( $user_id );
99 111 $meta_key = $wpdb->get_blog_prefix() . 'accessible_locale';
100 112
101 - return get_user_meta( $user_id, $meta_key );
113 + $locales = get_user_meta( $user_id, $meta_key );
114 +
115 + if ( bogo_get_prop( 'enus_deactivated' ) ) {
116 + $locales = array_diff( $locales, array( 'en_US' ) );
117 + }
118 +
119 + return $locales;
102 120 }
103 -
104 -?>