Changes from branches/3.1/wp-includes/admin-bar.php at r17509 to trunk/wp-includes/admin-bar.php at r18261
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/admin-bar.php
r17509 r18261 76 76 * @since 3.1.0 77 77 */ 78 function wp_admin_bar_my_account_menu( ) {79 global $ wp_admin_bar, $user_identity;78 function wp_admin_bar_my_account_menu( $wp_admin_bar ) { 79 global $user_identity; 80 80 81 81 $user_id = get_current_user_id(); … … 90 90 /* Add the "My Account" sub menus */ 91 91 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Edit My Profile' ), 'href' => get_edit_profile_url( $user_id ) ) ); 92 if ( is_multisite() ) 93 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); 92 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); 93 } 94 } 95 96 /** 97 * Add the "Dashboard"/"Visit Site" menu. 98 * 99 * @since 3.2.0 100 */ 101 function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { 102 $user_id = get_current_user_id(); 103 104 if ( 0 != $user_id ) { 105 if ( is_admin() ) 106 $wp_admin_bar->add_menu( array( 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); 107 elseif ( is_multisite() ) 108 $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); 94 109 else 95 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); 96 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); 110 $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); 97 111 } 98 112 } … … 103 117 * @since 3.1.0 104 118 */ 105 function wp_admin_bar_my_sites_menu( ) {106 global $wpdb , $wp_admin_bar;119 function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { 120 global $wpdb; 107 121 108 122 /* Add the 'My Sites' menu if the user has more than one site. */ … … 138 152 * @since 3.1.0 139 153 */ 140 function wp_admin_bar_shortlink_menu() { 141 global $wp_admin_bar; 142 154 function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { 143 155 $short = wp_get_shortlink( 0, 'query' ); 144 156 $id = 'get-shortlink'; … … 162 174 * @since 3.1.0 163 175 */ 164 function wp_admin_bar_edit_menu () { 165 global $wp_admin_bar; 166 167 $current_object = get_queried_object(); 168 169 if ( empty($current_object) ) 170 return; 171 172 if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) && $post_type_object->show_ui ) { 173 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link( $current_object->ID ) ) ); 174 } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) { 175 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) ); 176 function wp_admin_bar_edit_menu( $wp_admin_bar ) { 177 global $post, $tag; 178 179 if ( is_admin() ) { 180 $current_screen = get_current_screen(); 181 182 if ( 'post' == $current_screen->base 183 && 'add' != $current_screen->action 184 && ( $post_type_object = get_post_type_object( $post->post_type ) ) 185 && current_user_can( $post_type_object->cap->read_post, $post->ID ) 186 && ( $post_type_object->public ) ) 187 { 188 $wp_admin_bar->add_menu( array( 189 'id' => 'view', 190 'title' => $post_type_object->labels->view_item, 191 'href' => get_permalink( $post->ID ) 192 ) ); 193 } elseif ( 'edit-tags' == $current_screen->base 194 && isset( $tag ) && is_object( $tag ) 195 && ( $tax = get_taxonomy( $tag->taxonomy ) ) 196 && $tax->public ) 197 { 198 $wp_admin_bar->add_menu( array( 199 'id' => 'view', 200 'title' => $tax->labels->view_item, 201 'href' => get_term_link( $tag ) 202 ) ); 203 } 204 } else { 205 $current_object = get_queried_object(); 206 207 if ( empty($current_object) ) 208 return; 209 210 if ( ! empty( $current_object->post_type ) 211 && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) 212 && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) 213 && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) ) 214 { 215 $wp_admin_bar->add_menu( array( 216 'id' => 'edit', 217 'title' => $post_type_object->labels->edit_item, 218 'href' => get_edit_post_link( $current_object->ID ) 219 ) ); 220 } elseif ( ! empty( $current_object->taxonomy ) 221 && ( $tax = get_taxonomy( $current_object->taxonomy ) ) 222 && current_user_can( $tax->cap->edit_terms ) 223 && $tax->show_ui ) 224 { 225 $wp_admin_bar->add_menu( array( 226 'id' => 'edit', 227 'title' => $tax->labels->edit_item, 228 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) 229 ) ); 230 } 176 231 } 177 232 } … … 182 237 * @since 3.1.0 183 238 */ 184 function wp_admin_bar_new_content_menu() { 185 global $wp_admin_bar; 186 239 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 187 240 $actions = array(); 188 foreach ( (array) get_post_types( array( 'show_ ui' => true ), 'objects' ) as $ptype_obj ) {189 if ( true !== $ptype_obj->show_in_menu ||! current_user_can( $ptype_obj->cap->edit_posts ) )241 foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) { 242 if ( ! current_user_can( $ptype_obj->cap->edit_posts ) ) 190 243 continue; 191 244 192 $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); 193 } 245 $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->name_admin_bar, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); 246 } 247 248 if ( current_user_can( 'upload_files' ) ) 249 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'upload_files', 'new-media' ); 250 251 if ( current_user_can( 'manage_links' ) ) 252 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'manage_links', 'new-link' ); 253 254 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) 255 $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'create_users', 'new-user' ); 256 257 if ( ! is_multisite() && current_user_can( 'install_themes' ) ) 258 $actions[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'install_themes', 'new-theme' ); 259 260 if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) 261 $actions[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'install_plugins', 'new-plugin' ); 194 262 195 263 if ( empty( $actions ) ) … … 208 276 * @since 3.1.0 209 277 */ 210 function wp_admin_bar_comments_menu() { 211 global $wp_admin_bar; 212 278 function wp_admin_bar_comments_menu( $wp_admin_bar ) { 213 279 if ( !current_user_can('edit_posts') ) 214 280 return; … … 226 292 * @since 3.1.0 227 293 */ 228 function wp_admin_bar_appearance_menu() { 229 global $wp_admin_bar; 230 231 if ( !current_user_can('switch_themes') ) 294 function wp_admin_bar_appearance_menu( $wp_admin_bar ) { 295 // You can have edit_theme_options but not switch_themes. 296 if ( ! current_user_can('switch_themes') && ! current_user_can( 'edit_theme_options' ) ) 232 297 return; 233 298 234 299 $wp_admin_bar->add_menu( array( 'id' => 'appearance', 'title' => __('Appearance'), 'href' => admin_url('themes.php') ) ); 235 300 236 if ( !current_user_can('edit_theme_options') ) 237 return; 301 if ( ! current_user_can( 'edit_theme_options' ) ) 302 return; 303 304 if ( current_user_can( 'switch_themes' ) ) 305 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __('Themes'), 'href' => admin_url('themes.php') ) ); 238 306 239 307 if ( current_theme_supports( 'widgets' ) ) … … 242 310 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) 243 311 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); 312 313 if ( current_theme_supports( 'custom-background' ) ) 314 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __('Background'), 'href' => admin_url('themes.php?page=custom-background') ) ); 315 316 if ( current_theme_supports( 'custom-header' ) ) 317 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __('Header'), 'href' => admin_url('themes.php?page=custom-header') ) ); 244 318 } 245 319 … … 249 323 * @since 3.1.0 250 324 */ 251 function wp_admin_bar_updates_menu() { 252 global $wp_admin_bar; 253 325 function wp_admin_bar_updates_menu( $wp_admin_bar ) { 254 326 if ( !current_user_can('install_plugins') ) 255 327 return; … … 279 351 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count); 280 352 if ( $theme_update_count ) 281 $update_title[] = sprintf(_n('%d Theme Update', '%d Theme sUpdates', $theme_update_count), $theme_update_count);353 $update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $theme_update_count), $theme_update_count); 282 354 283 355 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; … … 308 380 */ 309 381 function _admin_bar_bump_cb() { ?> 310 <style type="text/css" >382 <style type="text/css" media="screen"> 311 383 html { margin-top: 28px !important; } 312 384 * html body { margin-top: 28px !important; } … … 316 388 317 389 /** 318 * Set the display status of the admin bar 390 * Set the display status of the admin bar. 319 391 * 320 392 * This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action. … … 364 436 * @access private 365 437 * 366 * @param string $context Context of this preference check, either 'admin' or 'front' 367 * @param int $user Optional. ID of the user to check, defaults to 0 for current user 368 * @return bool Whether the admin bar should be showing for this user 438 * @param string $context Context of this preference check, either 'admin' or 'front'. 439 * @param int $user Optional. ID of the user to check, defaults to 0 for current user. 440 * @return bool Whether the admin bar should be showing for this user. 369 441 */ 370 442 function _get_admin_bar_pref( $context, $user = 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.