From f114ff72ac16f51c77619bb3e2358165d8905764 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 7 Sep 2014 08:31:57 +0000 Subject: [PATCH] Don't display Edit links for posts and terms in toolbar if they are empty. props boonebgorges. fixes #29538. git-svn-id: https://develop.svn.wordpress.org/trunk@29714 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/admin-bar.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index cd1bb82a55..726c50a8cd 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -530,22 +530,24 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( 'edit_post', $current_object->ID ) - && $post_type_object->show_ui && $post_type_object->show_in_admin_bar ) + && $post_type_object->show_ui && $post_type_object->show_in_admin_bar + && $edit_post_link = get_edit_post_link( $current_object->ID ) ) { $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item, - 'href' => get_edit_post_link( $current_object->ID ) + 'href' => $edit_post_link ) ); } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) - && $tax->show_ui ) + && $tax->show_ui + && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) { $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 ) + 'href' => $edit_term_link ) ); } }