Changes from trunk/wp-includes/admin-bar.php at r18261 to branches/3.1/wp-includes/admin-bar.php at r17509
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/admin-bar.php
r18261 r17509 76 76 * @since 3.1.0 77 77 */ 78 function wp_admin_bar_my_account_menu( $wp_admin_bar) {79 global $ user_identity;78 function wp_admin_bar_my_account_menu() { 79 global $wp_admin_bar, $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 ) ) ); 94 else 95 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); 92 96 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); 93 97 } … … 95 99 96 100 /** 97 * Add the "Dashboard"/"Visit Site" menu.98 *99 * @since 3.2.0100 */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 ) ) );109 else110 $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );111 }112 }113 114 /**115 101 * Add the "My Sites/[Site Name]" menu and all submenus. 116 102 * 117 103 * @since 3.1.0 118 104 */ 119 function wp_admin_bar_my_sites_menu( $wp_admin_bar) {120 global $wpdb ;105 function wp_admin_bar_my_sites_menu() { 106 global $wpdb, $wp_admin_bar; 121 107 122 108 /* Add the 'My Sites' menu if the user has more than one site. */ … … 152 138 * @since 3.1.0 153 139 */ 154 function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { 140 function wp_admin_bar_shortlink_menu() { 141 global $wp_admin_bar; 142 155 143 $short = wp_get_shortlink( 0, 'query' ); 156 144 $id = 'get-shortlink'; … … 174 162 * @since 3.1.0 175 163 */ 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 } 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 ) ) ); 231 176 } 232 177 } … … 237 182 * @since 3.1.0 238 183 */ 239 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 184 function wp_admin_bar_new_content_menu() { 185 global $wp_admin_bar; 186 240 187 $actions = array(); 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 ) )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 ) ) 243 190 continue; 244 191 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' ); 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 } 262 194 263 195 if ( empty( $actions ) ) … … 276 208 * @since 3.1.0 277 209 */ 278 function wp_admin_bar_comments_menu( $wp_admin_bar ) { 210 function wp_admin_bar_comments_menu() { 211 global $wp_admin_bar; 212 279 213 if ( !current_user_can('edit_posts') ) 280 214 return; … … 292 226 * @since 3.1.0 293 227 */ 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' ) ) 228 function wp_admin_bar_appearance_menu() { 229 global $wp_admin_bar; 230 231 if ( !current_user_can('switch_themes') ) 297 232 return; 298 233 299 234 $wp_admin_bar->add_menu( array( 'id' => 'appearance', 'title' => __('Appearance'), 'href' => admin_url('themes.php') ) ); 300 235 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') ) ); 236 if ( !current_user_can('edit_theme_options') ) 237 return; 306 238 307 239 if ( current_theme_supports( 'widgets' ) ) … … 310 242 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) 311 243 $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') ) );318 244 } 319 245 … … 323 249 * @since 3.1.0 324 250 */ 325 function wp_admin_bar_updates_menu( $wp_admin_bar ) { 251 function wp_admin_bar_updates_menu() { 252 global $wp_admin_bar; 253 326 254 if ( !current_user_can('install_plugins') ) 327 255 return; … … 351 279 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count); 352 280 if ( $theme_update_count ) 353 $update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $theme_update_count), $theme_update_count);281 $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count); 354 282 355 283 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; … … 380 308 */ 381 309 function _admin_bar_bump_cb() { ?> 382 <style type="text/css" media="screen">310 <style type="text/css"> 383 311 html { margin-top: 28px !important; } 384 312 * html body { margin-top: 28px !important; } … … 388 316 389 317 /** 390 * Set the display status of the admin bar .318 * Set the display status of the admin bar 391 319 * 392 320 * This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action. … … 436 364 * @access private 437 365 * 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 .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 441 369 */ 442 370 function _get_admin_bar_pref( $context, $user = 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.