Admin bar visibility prefs. Props duck_. see #15829
git-svn-id: http://svn.automattic.com/wordpress/trunk@17032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
de0fc3026a
commit
58e65d1855
|
@ -118,6 +118,8 @@ function edit_user( $user_id = 0 ) {
|
|||
if ( $update ) {
|
||||
$user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
|
||||
$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
|
||||
$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
|
||||
$user->show_admin_bar_admin = isset( $_POST['admin_bar_admin'] ) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
|
||||
|
|
|
@ -211,10 +211,19 @@ if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
|
|||
<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
|
||||
<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
do_action('personal_options', $profileuser);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Admin Bar')?></th>
|
||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Admin Bar') ?></span></legend>
|
||||
<label for="admin_bar_front">
|
||||
<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" <?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
|
||||
<?php _e( 'Display the admin bar on the front end' ); ?></label><br />
|
||||
<label for="admin_bar_admin">
|
||||
<input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" <?php checked( _get_admin_bar_pref( 'admin', $profileuser->ID ) ); ?> />
|
||||
<?php _e( 'Display the admin bar in the dashboard' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php do_action('personal_options', $profileuser); ?>
|
||||
</table>
|
||||
<?php
|
||||
if ( IS_PROFILE_PAGE )
|
||||
|
|
|
@ -299,6 +299,26 @@ function _admin_bar_bump_cb() { ?>
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display status of the admin bar
|
||||
*
|
||||
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param bool $show Whether to allow the admin bar to show.
|
||||
* @return void
|
||||
*/
|
||||
function show_admin_bar( $show ) {
|
||||
global $show_admin_bar;
|
||||
$show_admin_bar = (bool) $show;
|
||||
|
||||
// Remove the object if we are not going to be showing
|
||||
// Otherwise you have to call this function prior to the init hook for it to work!
|
||||
if ( ! $show_admin_bar && isset( $GLOBALS['wp_admin_bar'] ) )
|
||||
$GLOBALS['wp_admin_bar'] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the admin bar should be showing.
|
||||
*
|
||||
|
@ -314,10 +334,11 @@ function is_admin_bar_showing() {
|
|||
return false;
|
||||
|
||||
if ( ! isset( $show_admin_bar ) ) {
|
||||
if ( ! is_user_logged_in() || ( is_admin() && ! is_multisite() ) ) {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
$show_admin_bar = false;
|
||||
} else {
|
||||
$show_admin_bar = true;
|
||||
$context = is_admin() ? 'admin' : 'front';
|
||||
$show_admin_bar = _get_admin_bar_pref( $context );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,4 +346,22 @@ function is_admin_bar_showing() {
|
|||
|
||||
return $show_admin_bar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the admin bar display preference of a user based on context.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
*
|
||||
* @param string $context Context of this preference check, either 'admin' or 'front'
|
||||
* @param int $user Optional. ID of the user to check, defaults to 0 for current user
|
||||
* @return bool Whether the admin bar should be showing for this user
|
||||
*/
|
||||
function _get_admin_bar_pref( $context, $user = 0 ) {
|
||||
$pref = get_user_option( "show_admin_bar_{$context}", $user );
|
||||
if ( false === $pref )
|
||||
return 'admin' != $context || is_multisite();
|
||||
|
||||
return 'true' === $pref;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -4471,24 +4471,4 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display status of the admin bar
|
||||
*
|
||||
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param bool $show Whether to allow the admin bar to show.
|
||||
* @return void
|
||||
*/
|
||||
function show_admin_bar( $show ) {
|
||||
global $show_admin_bar;
|
||||
$show_admin_bar = (bool) $show;
|
||||
|
||||
// Remove the object if we are not going to be showing
|
||||
// Otherwise you have to call this function prior to the init hook for it to work!
|
||||
if ( ! $show_admin_bar && isset( $GLOBALS['wp_admin_bar'] ) )
|
||||
$GLOBALS['wp_admin_bar'] = null;
|
||||
}
|
||||
|
||||
?>
|
|
@ -507,8 +507,7 @@ class WP_User_Query {
|
|||
if ( !empty( $qv['include'] ) ) {
|
||||
$ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
|
||||
$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
|
||||
}
|
||||
elseif ( !empty($qv['exclude']) ) {
|
||||
} elseif ( !empty($qv['exclude']) ) {
|
||||
$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
|
||||
$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
|
||||
}
|
||||
|
@ -1447,6 +1446,12 @@ function wp_insert_user($userdata) {
|
|||
if ( empty($user_registered) )
|
||||
$user_registered = gmdate('Y-m-d H:i:s');
|
||||
|
||||
if ( empty($show_admin_bar_front) )
|
||||
$show_admin_bar_front = 'true';
|
||||
|
||||
if ( empty($show_admin_bar_admin) )
|
||||
$show_admin_bar_admin = is_multisite() ? 'true' : 'false';
|
||||
|
||||
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
|
||||
|
||||
if ( $user_nicename_check ) {
|
||||
|
@ -1470,14 +1475,16 @@ function wp_insert_user($userdata) {
|
|||
$user_id = (int) $wpdb->insert_id;
|
||||
}
|
||||
|
||||
update_user_meta( $user_id, 'first_name', $first_name);
|
||||
update_user_meta( $user_id, 'last_name', $last_name);
|
||||
update_user_meta( $user_id, 'first_name', $first_name );
|
||||
update_user_meta( $user_id, 'last_name', $last_name );
|
||||
update_user_meta( $user_id, 'nickname', $nickname );
|
||||
update_user_meta( $user_id, 'description', $description );
|
||||
update_user_meta( $user_id, 'rich_editing', $rich_editing);
|
||||
update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts);
|
||||
update_user_meta( $user_id, 'admin_color', $admin_color);
|
||||
update_user_meta( $user_id, 'use_ssl', $use_ssl);
|
||||
update_user_meta( $user_id, 'rich_editing', $rich_editing );
|
||||
update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts );
|
||||
update_user_meta( $user_id, 'admin_color', $admin_color );
|
||||
update_user_meta( $user_id, 'use_ssl', $use_ssl );
|
||||
update_user_meta( $user_id, 'show_admin_bar_front', $show_admin_bar_front );
|
||||
update_user_meta( $user_id, 'show_admin_bar_admin', $show_admin_bar_admin );
|
||||
|
||||
$user = new WP_User($user_id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue