| @@ -7,11 +7,10 @@ | ||
| 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 | - } | |
| 14 | 13 | |
| 15 | 14 | $wp_admin_bar->add_menu( array( |
| 16 | 15 | 'parent' => 'top-secondary', |
| 17 | 16 | 'id' => 'bogo-user-locale', |
| @@ -18,9 +17,8 @@ | ||
| 18 | 17 | 'title' => '✔ ' . $current_language ) ); |
| 19 | 18 | |
| 20 | 19 | $available_languages = bogo_available_languages( array( |
| 21 | 20 | 'exclude' => array( $current_locale ), |
| 22 | - 'exclude_enus_if_inactive' => true, | |
| 23 | 21 | 'current_user_can_access' => true ) ); |
| 24 | 22 | |
| 25 | 23 | foreach ( $available_languages as $locale => $lang ) { |
| 26 | 24 | $url = admin_url( 'profile.php?action=bogo-switch-locale&locale=' . $locale ); |
| @@ -60,37 +58,25 @@ | ||
| 60 | 58 | } |
| 61 | 59 | } |
| 62 | 60 | |
| 63 | 61 | function bogo_get_user_locale( $user_id = 0 ) { |
| 64 | - global $current_user; | |
| 65 | - | |
| 66 | - $default_locale = bogo_get_default_locale(); | |
| 67 | - $user_id = absint( $user_id ); | |
| 68 | - | |
| 69 | - if ( ! $user_id ) { | |
| 70 | - if ( function_exists( 'wp_get_current_user' ) && ! empty( $current_user ) ) { | |
| 71 | - $user_id = get_current_user_id(); | |
| 72 | - } elseif ( ! $user_id = apply_filters( 'determine_current_user', false ) ) { | |
| 73 | - return $default_locale; | |
| 74 | - } | |
| 62 | + if ( ! $user_id = absint( $user_id ) ) { | |
| 63 | + $user_id = get_current_user_id(); | |
| 75 | 64 | } |
| 76 | 65 | |
| 77 | 66 | $locale = get_user_option( 'locale', $user_id ); |
| 78 | 67 | |
| 79 | - if ( bogo_is_available_locale( $locale ) | |
| 80 | - && ( 'en_US' != $locale || ! bogo_get_prop( 'enus_deactivated' ) ) | |
| 81 | - && user_can( $user_id, 'bogo_access_locale', $locale ) ) { | |
| 68 | + if ( user_can( $user_id, 'bogo_access_locale', $locale ) ) { | |
| 82 | 69 | return $locale; |
| 83 | 70 | } |
| 84 | 71 | |
| 72 | + $default_locale = bogo_get_default_locale(); | |
| 73 | + | |
| 85 | 74 | if ( user_can( $user_id, 'bogo_access_locale', $default_locale ) ) { |
| 86 | 75 | return $default_locale; |
| 87 | 76 | } |
| 88 | 77 | |
| 89 | - $available_locales = bogo_available_locales( array( | |
| 90 | - 'exclude_enus_if_inactive' => true ) ); | |
| 91 | - | |
| 92 | - foreach ( $available_locales as $locale ) { | |
| 78 | + foreach ( (array) bogo_available_locales() as $locale ) { | |
| 93 | 79 | if ( user_can( $user_id, 'bogo_access_locale', $locale ) ) { |
| 94 | 80 | return $locale; |
| 95 | 81 | } |
| 96 | 82 | } |
| @@ -103,12 +89,8 @@ | ||
| 103 | 89 | |
| 104 | 90 | $user_id = absint( $user_id ); |
| 105 | 91 | $meta_key = $wpdb->get_blog_prefix() . 'accessible_locale'; |
| 106 | 92 | |
| 107 | - $locales = get_user_meta( $user_id, $meta_key ); | |
| 93 | + return get_user_meta( $user_id, $meta_key ); | |
| 94 | +} | |
| 108 | 95 | |
| 109 | - if ( bogo_get_prop( 'enus_deactivated' ) ) { | |
| 110 | - $locales = array_diff( $locales, array( 'en_US' ) ); | |
| 111 | - } | |
| 112 | - | |
| 113 | - return $locales; | |
| 114 | -} | |
| 96 | +?> | |