PluginProbe
Adminimize / 1.9.1
Adminimize v1.9.1
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
← All changes | inc-setup/remove-admin-bar.php +66 -110 1.11.4 → 1.9.1 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 /**
3 3 * @package Adminimize
4 - * @subpackage Remove Admin Bar of > WP 3.3 Setup
4 + * @subpackage Remove Admin Bar of WP 3.3 Setup
5 5 * @author Frank Bültge
6 6 */
7 7 if ( ! function_exists( 'add_action' ) ) {
8 8 echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
@@ -16,9 +16,9 @@
16 16 * Change the var of Admin Bar in WP 3.3
17 17 *
18 18 * @param array $admin_bar_keys
19 19 */
20 -function _mw_adminimize_customize_admin_bar( array $admin_bar_keys ) {
20 +function _mw_adminimize_customize_admin_bar( $admin_bar_keys = array() ) {
21 21
22 22 if ( ! is_admin_bar_showing() ) {
23 23 return;
24 24 }
@@ -40,17 +40,18 @@
40 40
41 41 /**
42 42 * Add Logout link to admin abr in wp 3.3
43 43 *
44 - * @param $wp_admin_bar WP_Admin_Bar
44 + * @param $wp_admin_bar
45 45 */
46 46 function _mw_adminimize_add_logout( $wp_admin_bar ) {
47 47
48 48 $user_id = get_current_user_id();
49 49 $_mw_adminimize_ui_redirect = (int) _mw_adminimize_get_option_value( '_mw_adminimize_ui_redirect' );
50 - $redirect = '';
51 50 if ( 1 === $_mw_adminimize_ui_redirect ) {
52 51 $redirect = '&amp;redirect_to=' . get_option( 'siteurl' );
52 + } else {
53 + $redirect = '';
53 54 }
54 55
55 56 if ( ! $user_id ) {
56 57 return;
@@ -65,32 +66,17 @@
65 66 )
66 67 );
67 68 }
68 69
69 -/**
70 - * Add stylesheet for see the the admin bar item also on mobile.
71 - */
72 -function _mw_adminimize_admin_bar_style() {
73 - ?>
74 - <style type="text/css">
75 - #wpadminbar #wp-admin-bar-mw-account { display: block; }
76 - </style>
77 - <?php
78 -}
79 -
80 -/**
81 - * Add Logout link include user info.
82 - *
83 - * @param $wp_admin_bar WP_Admin_Bar
84 - */
85 70 function _mw_adminimize_add_user_logout( $wp_admin_bar ) {
86 71
87 72 $user_id = get_current_user_id();
88 73 $current_user = wp_get_current_user();
89 74 $_mw_adminimize_ui_redirect = (int) _mw_adminimize_get_option_value( '_mw_adminimize_ui_redirect' );
90 - $redirect = '';
91 75 if ( 1 === $_mw_adminimize_ui_redirect ) {
92 76 $redirect = '&amp;redirect_to=' . get_option( 'siteurl' );
77 + } else {
78 + $redirect = '';
93 79 }
94 80
95 81 if ( ! $user_id ) {
96 82 return;
@@ -107,30 +93,15 @@
107 93 )
108 94 );
109 95 }
110 96
111 -add_action( 'init', '_mw_adminimize_set_logout_menu', 2 );
112 -/**
113 - * Change logout, user info link in Admin bar.
114 - *
115 - * @return void
116 - */
117 -function _mw_adminimize_set_logout_menu() {
97 +function _mw_adminimize_set_menu_option_33() {
118 98
119 - if ( ! is_user_logged_in() ) {
120 - return;
121 - }
122 -
123 99 // exclude super admin
124 100 if ( _mw_adminimize_exclude_super_admin() ) {
125 - return;
101 + return NULL;
126 102 }
127 103
128 - // Leave the settings screen from Adminimize to see all areas on settings.
129 - if ( _mw_adminimize_exclude_settings_page() ) {
130 - return;
131 - }
132 -
133 104 $user_roles = _mw_adminimize_get_all_user_roles();
134 105
135 106 foreach ( $user_roles as $role ) {
136 107 $disabled_menu_[ $role ] = _mw_adminimize_get_option_value(
@@ -140,9 +111,9 @@
140 111 'mw_adminimize_disabled_submenu_' . $role . '_items'
141 112 );
142 113 }
143 114
144 - $_mw_adminimize_user_info = (int) _mw_adminimize_get_option_value( '_mw_adminimize_user_info' );
115 + $_mw_adminimize_user_info = (int) _mw_adminimize_get_option_value( '_mw_adminimize_user_info' );
145 116 // change user-info
146 117 switch ( $_mw_adminimize_user_info ) {
147 118 case 1:
148 119 add_action( 'wp_before_admin_bar_render', '_mw_adminimize_remove_my_account' );
@@ -149,16 +120,12 @@
149 120 break;
150 121 case 2:
151 122 add_action( 'wp_before_admin_bar_render', '_mw_adminimize_remove_my_account' );
152 123 add_action( 'admin_bar_menu', '_mw_adminimize_add_logout', 0 );
153 - add_action( 'wp_head', '_mw_adminimize_admin_bar_style' );
154 - add_action( 'admin_head', '_mw_adminimize_admin_bar_style' );
155 124 break;
156 125 case 3:
157 126 add_action( 'wp_before_admin_bar_render', '_mw_adminimize_remove_my_account' );
158 127 add_action( 'admin_bar_menu', '_mw_adminimize_add_user_logout', 0 );
159 - add_action( 'wp_head', '_mw_adminimize_admin_bar_style' );
160 - add_action( 'admin_head', '_mw_adminimize_admin_bar_style' );
161 128 break;
162 129 }
163 130 }
164 131
@@ -163,96 +130,91 @@
163 130 }
164 131
165 132 /**
166 133 * Remove Admin Bar
167 - *
168 - * @return void
169 134 */
170 135 function _mw_adminimize_remove_admin_bar() {
171 136
172 - if ( ! is_user_logged_in() ) {
173 - return;
174 - }
175 -
176 137 // exclude super admin
177 138 if ( _mw_adminimize_exclude_super_admin() ) {
178 - return;
139 + return NULL;
179 140 }
180 141
181 - // Leave the settings screen from Adminimize to see all areas on settings.
182 - if ( _mw_adminimize_exclude_settings_page() ) {
183 - return;
184 - }
142 + global $wp_version;
185 143
186 144 $user_roles = _mw_adminimize_get_all_user_roles();
187 - $disabled_global_option_ = array();
188 145
189 146 foreach ( $user_roles as $role ) {
190 - $disabled_global_option_[ $role ] = (array) _mw_adminimize_get_option_value(
147 + $disabled_global_option_[ $role ] = _mw_adminimize_get_option_value(
191 148 'mw_adminimize_disabled_global_option_' . $role . '_items'
192 149 );
193 150 }
194 151
195 - $mw_global_options = array();
196 - $user = wp_get_current_user();
197 -
198 152 foreach ( $user_roles as $role ) {
199 -
200 - if ( in_array( $role, $user->roles, FALSE )
201 - && _mw_adminimize_current_user_has_role( $role )
202 - ) {
203 - // Create array about all items with all affected roles, important for multiple roles.
204 - foreach ( $disabled_global_option_[ $role ] as $global_item ) {
205 - $mw_global_options[] = $global_item;
206 - }
153 + if ( ! isset( $disabled_global_option_[ $role ][ '0' ] ) ) {
154 + $disabled_global_option_[ $role ][ '0' ] = '';
207 155 }
208 -
209 156 }
210 157
211 - // Support Multiple Roles for users.
212 - if ( _mw_adminimize_get_option_value( 'mw_adminimize_multiple_roles' ) && 1 < count( $user->roles ) ) {
213 - $mw_global_options = _mw_adminimize_get_duplicate( $mw_global_options );
214 - }
215 -
216 158 $remove_adminbar = FALSE;
217 - // Check for admin bar selector to set to remove the Admin Bar.
218 - if ( _mw_adminimize_recursive_in_array( '.show-admin-bar', $mw_global_options ) ) {
219 - $remove_adminbar = TRUE;
159 + // new 1.7.8
160 + foreach ( $user_roles as $role ) {
161 + $user = wp_get_current_user();
162 + if ( is_array( $user->roles ) && in_array( $role, $user->roles ) ) {
163 + if ( _mw_adminimize_current_user_has_role( $role )
164 + && isset( $disabled_global_option_[ $role ] )
165 + && is_array( $disabled_global_option_[ $role ] )
166 + ) {
167 + if ( _mw_adminimize_recursive_in_array( '.show-admin-bar', $disabled_global_option_[ $role ] ) ) {
168 + $remove_adminbar = TRUE;
169 + }
170 + }
171 + }
220 172 }
221 173
222 174 if ( $remove_adminbar ) {
223 - if ( ! is_admin_bar_showing() ) {
224 - return;
225 - }
175 + // for deactivate admin bar in WP smaller WP 3.3
176 + if ( version_compare( $wp_version, '3.3alpha', '<=' ) ) {
177 + add_filter( 'show_admin_bar', '__return_false' );
178 + wp_deregister_script( 'admin-bar' );
179 + wp_deregister_style( 'admin-bar' );
180 + remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
181 + remove_action( 'wp_head', '_admin_bar_bump_cb' );
182 + } else {
183 + if ( ! is_admin_bar_showing() ) {
184 + return FALSE;
185 + }
226 186
227 - add_filter( 'show_admin_bar', '__return_false' );
228 - add_filter( 'wp_admin_bar_class', '__return_false' );
229 - add_filter( 'show_wp_pointer_admin_bar', '__return_false' );
230 - wp_deregister_script( 'admin-bar' );
231 - wp_deregister_style( 'admin-bar' );
232 - remove_action( 'init', '_wp_admin_bar_init' );
233 - remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
234 - remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
187 + add_filter( 'show_admin_bar', '__return_false' );
188 + add_filter( 'wp_admin_bar_class', '__return_false' );
189 + add_filter( 'show_wp_pointer_admin_bar', '__return_false' );
190 + wp_deregister_script( 'admin-bar' );
191 + wp_deregister_style( 'admin-bar' );
192 + remove_action( 'init', '_wp_admin_bar_init' );
193 + remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
194 + remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
235 195
236 - // maybe also: 'wp_head'
237 - foreach ( array( 'wp_head', 'admin_head' ) as $hook ) {
238 - add_action(
239 - $hook,
240 - create_function(
241 - '',
242 - "echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu {
196 + // maybe also: 'wp_head'
197 + foreach ( array( 'wp_head', 'admin_head' ) as $hook ) {
198 + add_action(
199 + $hook,
200 + create_function(
201 + '',
202 + "echo '<style>body.admin-bar, body.admin-bar #wpcontent, body.admin-bar #adminmenu {
243 203 padding-top: 0 !important;
244 204 }
245 205 html.wp-toolbar {
246 206 padding-top: 0 !important;
247 207 }</style>';"
248 - )
249 - );
250 - }
208 + )
209 + );
210 + }
251 211
252 - add_action( 'in_admin_header', '_mw_adminimize_restore_links' );
212 + add_action( 'in_admin_header', '_mw_adminimize_restore_links' );
213 + } // end else version 3.3
214 + } // end if $remove_adminbar TRUE
253 215
254 - } // end if $remove_adminbar TRUE
216 + return NULL;
255 217 }
256 218
257 219 /**
258 220 * Add Site Link in Menu
@@ -296,12 +258,11 @@
296 258 ) . '" target="_blank">' . get_bloginfo( 'name' ) . '</a>';
297 259 ?>
298 260 <div id="mw_adminimize_login">
299 261 <?php
262 + wp_get_current_user();
300 263 $current_user = wp_get_current_user();
301 - if ( empty( $_mw_adminimize_user_info ) || 0 === $_mw_adminimize_user_info
302 - || 3 === $_mw_adminimize_user_info
303 - ) {
264 + if ( empty( $_mw_adminimize_user_info ) || 0 === $_mw_adminimize_user_info || 3 === $_mw_adminimize_user_info ) {
304 265 if ( ! ( $current_user instanceof WP_User ) ) {
305 266 return;
306 267 }
307 268 echo ' ' . $current_user->user_login . ' ';
@@ -318,20 +279,15 @@
318 279 }
319 280 }
320 281 }
321 282
322 - if ( empty( $_mw_adminimize_user_info ) || 0 === $_mw_adminimize_user_info
323 - || 2 === $_mw_adminimize_user_info
324 - || 3 === $_mw_adminimize_user_info
325 - ) {
326 - ?> | <?php echo '<a href="' . wp_logout_url() . '" title="' . esc_attr__(
283 + if ( empty( $_mw_adminimize_user_info ) || 0 == $_mw_adminimize_user_info || 2 == $_mw_adminimize_user_info || 3 == $_mw_adminimize_user_info ) {
284 + ?> | <?php echo '<a href="' . wp_logout_url() . '" title="' . esc_attr__( 'Log Out' ) . '">' . esc_attr__(
327 285 'Log Out'
328 - ) . '">' . esc_attr__(
329 - 'Log Out'
330 286 ) . '</a>';
331 287 }
332 288 ?>
333 289 </div>
334 290 </div>
335 - <?php
291 +<?php
336 292 }
337 293