PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.5
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.5
4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 All 339 releases
profile-builder / admin / admin-bar.php

admin-bar.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.5, at admin/admin-bar.php

119 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function that creates the "Show/Hide the Admin Bar on the Front-End" submenu page
4 *
5 * @since v.2.0
6 *
7 * @return void
8 */
9 function wppb_show_hide_admin_bar_submenu_page() {
10 add_submenu_page( 'profile-builder', __( 'Show/Hide the Admin Bar on the Front-End', 'profilebuilder' ), __( 'Admin Bar Settings', 'profilebuilder' ), 'manage_options', 'profile-builder-admin-bar-settings', 'wppb_show_hide_admin_bar_content' );
11 }
12 add_action( 'admin_menu', 'wppb_show_hide_admin_bar_submenu_page', 4 );
13
14
15 function wppb_generate_admin_bar_default_values( $roles ){
16 $wppb_display_admin_settings = get_option( 'wppb_display_admin_settings', 'not_found' );
17
18 if ( $wppb_display_admin_settings == 'not_found' ){
19 if( !empty( $roles ) ){
20 $admin_settings = array();
21 foreach ( $roles as $role ){
22 if( !empty( $role['name'] ) )
23 $admin_settings[$role['name']] = 'default';
24 }
25
26 update_option( 'wppb_display_admin_settings', $admin_settings );
27 }
28 }
29 }
30
31
32 /**
33 * Function that adds content to the "Show/Hide the Admin Bar on the Front-End" submenu page
34 *
35 * @since v.2.0
36 *
37 * @return string
38 */
39 function wppb_show_hide_admin_bar_content() {
40 global $wp_roles;
41
42 wppb_generate_admin_bar_default_values( $wp_roles );
43 ?>
44
45 <div class="wrap wppb-wrap wppb-admin-bar">
46
47 <h2><?php _e( 'Admin Bar Settings', 'profilebuilder' );?></h2>
48 <p><?php _e( 'Choose which user roles view the admin bar in the front-end of the website.', 'profilebuilder' ); ?>
49 <form method="post" action="options.php#show-hide-admin-bar">
50 <?php
51 $admin_bar_settings = get_option( 'wppb_display_admin_settings' );
52 settings_fields( 'wppb_display_admin_settings' );
53 ?>
54 <table class="widefat">
55 <thead>
56 <tr>
57 <th class="row-title" scope="col"><?php _e('User-Role', 'profilebuilder');?></th>
58 <th scope="col"><?php _e('Visibility', 'profilebuilder');?></th>
59 </tr>
60 </thead>
61 <tbody>
62 <?php
63 $alt_i = 0;
64 foreach ( $wp_roles->roles as $role ) {
65 $alt_i++;
66 $key = $role['name'];
67 $setting_exists = !empty( $admin_bar_settings[$key] );
68 $alt_class = ( ( $alt_i%2 == 0 ) ? ' class="alternate"' : '' );
69
70 echo'<tr'.$alt_class.'>
71 <td>'.translate_user_role($key).'</td>
72 <td>
73 <span><input id="rd'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="default"'.( ( !$setting_exists || $admin_bar_settings[$key] == 'default' ) ? ' checked' : '' ).'/><label for="rd'.$key.'">'.__( 'Default', 'profilebuilder' ).'</label></span>
74 <span><input id="rs'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="show"'.( ( $setting_exists && $admin_bar_settings[$key] == 'show') ? ' checked' : '' ).'/><label for="rs'.$key.'">'.__( 'Show', 'profilebuilder' ).'</label></span>
75 <span><input id="rh'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="hide"'.( ( $setting_exists && $admin_bar_settings[$key] == 'hide') ? ' checked' : '' ).'/><label for="rh'.$key.'">'.__( 'Hide', 'profilebuilder' ).'</label></span>
76 </td>
77 </tr>';
78 }
79 ?>
80
81 </table>
82
83 <div id="wppb_submit_button_div">
84 <input type="hidden" name="action" value="update" />
85 <p class="submit">
86 <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
87 </p>
88 </div>
89
90 </form>
91
92 </div>
93 <?php
94 }
95
96 /**
97 * Function that changes the username on the top right menu (admin bar)
98 *
99 * @since v.2.0
100 *
101 * @return string
102 */
103 function wppb_replace_username_on_admin_bar( $wp_admin_bar ) {
104 $wppb_general_settings = get_option( 'wppb_general_settings' );
105
106 if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ){
107 $current_user = wp_get_current_user();
108
109 $my_account_main = $wp_admin_bar->get_node( 'my-account' );
110 $new_title1 = str_replace( $current_user->display_name, $current_user->user_email, $my_account_main->title );
111 $wp_admin_bar->add_node( array( 'id' => 'my-account', 'title' => $new_title1 ) );
112
113 $my_account_sub = $wp_admin_bar->get_node( 'user-info' );
114 $wp_admin_bar->add_node( array( 'parent' => 'user-actions', 'id' => 'user-info', 'title' => get_avatar( $current_user->ID, 64 )."<span class='display-name'>{$current_user->user_email}</span>", 'href' => get_edit_profile_url( $current_user->ID ), 'meta' => array( 'tabindex' => -1 ) ) );
115 }
116
117 return $wp_admin_bar;
118 }
119 add_filter( 'admin_bar_menu', 'wppb_replace_username_on_admin_bar', 25 );