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 | admin/includes/user.php +46 -31 trunk2.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 -add_action( 'personal_options_update', 'bogo_update_user_option', 10, 1 );
4 -add_action( 'edit_user_profile_update', 'bogo_update_user_option', 10, 1 );
3 +add_action( 'personal_options_update', 'bogo_update_user_option' );
4 +add_action( 'edit_user_profile_update', 'bogo_update_user_option' );
5 5
6 6 function bogo_update_user_option( $user_id ) {
7 7 global $wpdb;
8 8
@@ -34,28 +34,33 @@
34 34 }
35 35 }
36 36 }
37 37
38 +add_action( 'personal_options', 'bogo_set_locale_options' );
38 39
39 -add_action( 'personal_options', 'bogo_set_locale_options', 10, 1 );
40 -
41 40 function bogo_set_locale_options( $profileuser ) {
42 - if ( is_network_admin() or IS_PROFILE_PAGE ) {
41 + if ( is_network_admin() ) {
43 42 return;
44 43 }
45 44
46 - if ( ! user_can( $profileuser, 'bogo_access_all_locales' ) ) {
45 + if ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
46 + bogo_select_own_locale( $profileuser );
47 + } elseif ( ! user_can( $profileuser, 'bogo_access_all_locales' ) ) {
47 48 bogo_set_accessible_locales( $profileuser );
48 49 }
49 50 }
50 51
51 -
52 52 function bogo_set_accessible_locales( $profileuser ) {
53 53 $available_languages = bogo_available_languages( array(
54 - 'orderby' => 'value',
55 - ) );
54 + 'exclude_enus_if_inactive' => true,
55 + 'orderby' => 'value' ) );
56 + $accessible_locales = bogo_get_user_accessible_locales( $profileuser->ID );
56 57
57 - $accessible_locales = bogo_get_user_accessible_locales( $profileuser->ID );
58 + if ( empty( $accessible_locales ) ) {
59 + $accessible_locales = array_keys( $available_languages );
60 + } else {
61 + $accessible_locales = bogo_filter_locales( $accessible_locales );
62 + }
58 63
59 64 ?>
60 65
61 66 <!-- Bogo plugin -->
@@ -66,34 +71,44 @@
66 71 <span class="description"><?php echo esc_html( __( 'This user is allowed to access the following locales:', 'bogo' ) ); ?></span><br />
67 72 <fieldset class="bogo-locale-options">
68 73
69 74 <?php
75 + foreach ( $available_languages as $locale => $language ) :
76 + $checked = in_array( $locale, $accessible_locales );
77 + $id_attr = 'bogo_accessible_locale-' . $locale;
78 +?>
79 +<label class="bogo-locale-option<?php echo $checked ? ' checked' : ''; ?>" for="<?php echo $id_attr; ?>">
80 +<input type="checkbox" id="<?php echo $id_attr; ?>" name="bogo_accessible_locales[]" value="<?php echo esc_attr( $locale ); ?>"<?php echo $checked ? ' checked="checked"' : ''; ?> /><?php echo esc_html( $language ); ?>
81 +</label>
82 +<?php
83 + endforeach;
84 +?>
85 +</fieldset>
86 +</td>
87 +</tr>
70 88
71 - foreach ( $available_languages as $locale => $language ) {
72 - $checked = in_array( $locale, $accessible_locales );
73 - $id_attr = sprintf( 'bogo_accessible_locale-%s', $locale );
89 +<?php
90 +}
74 91
75 - $checkbox = sprintf(
76 - '<label %1$s><input %2$s />%3$s</label>',
77 - bogo_format_atts( array(
78 - 'class' => 'bogo-locale-option' . ( $checked ? ' checked' : '' ),
79 - 'for' => $id_attr,
80 - ) ),
81 - bogo_format_atts( array(
82 - 'type' => 'checkbox',
83 - 'id' => $id_attr,
84 - 'name' => 'bogo_accessible_locales[]',
85 - 'value' => $locale,
86 - 'checked' => $checked,
87 - ) ),
88 - $language
89 - );
92 +function bogo_select_own_locale( $profileuser ) {
93 + $available_languages = bogo_available_languages( array(
94 + 'exclude_enus_if_inactive' => true,
95 + 'orderby' => 'value',
96 + 'current_user_can_access' => true ) );
90 97
91 - echo wp_kses( $checkbox, 'bogo_form_inside' ) . "\n";
92 - }
98 + $selected = bogo_get_user_locale( $profileuser->ID );
93 99
94 100 ?>
95 -</fieldset>
101 +
102 +<!-- Bogo plugin -->
103 +<tr>
104 +<th scope="row"><?php echo esc_html( __( 'Locale', 'bogo' ) ); ?></th>
105 +<td>
106 +<select name="bogo_own_locale">
107 +<?php foreach ( $available_languages as $locale => $lang ) : ?>
108 +<option value="<?php echo esc_attr( $locale ); ?>" <?php selected( $locale, $selected ); ?>><?php echo esc_html( $lang ); ?></option>
109 +<?php endforeach; ?>
110 +</select>
96 111 </td>
97 112 </tr>
98 113
99 114 <?php