Changeset 45590 for trunk/src/wp-includes/admin-bar.php
- Timestamp:
- 07/02/2019 11:41:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/admin-bar.php
r45269 r45590 689 689 $current_screen = get_current_screen(); 690 690 $post = get_post(); 691 if ( 'post' == $current_screen->base ) { 692 $post_type_object = get_post_type_object( $post->post_type ); 693 } elseif ( 'edit' == $current_screen->base ) { 694 $post_type_object = get_post_type_object( $current_screen->post_type ); 695 } 691 696 692 697 if ( 'post' == $current_screen->base 693 698 && 'add' != $current_screen->action 694 && ( $post_type_object = get_post_type_object( $post->post_type ))699 && ( $post_type_object ) 695 700 && current_user_can( 'read_post', $post->ID ) 696 701 && ( $post_type_object->public ) … … 716 721 } 717 722 } elseif ( 'edit' == $current_screen->base 718 && ( $post_type_object = get_post_type_object( $current_screen->post_type ))723 && ( $post_type_object ) 719 724 && ( $post_type_object->public ) 720 725 && ( $post_type_object->show_in_admin_bar ) … … 728 733 ) 729 734 ); 730 } elseif ( 'term' == $current_screen->base 731 && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )732 && ( $tax = get_taxonomy( $tag->taxonomy ) )733 && is_taxonomy_viewable( $tax ) ) {734 $wp_admin_bar->add_menu(735 array(736 'id' => 'view',737 'title' => $tax->labels->view_item,738 'href' => get_term_link( $tag ),739 ) 740 );741 } elseif ( 'user-edit' == $current_screen->base 742 && isset( $user_id )743 && ( $user_object = get_userdata( $user_id ) )744 && $user_object->exists()745 && $view_link = get_author_posts_url( $user_object->ID ) ) {746 $wp_admin_bar->add_menu(747 array(748 'id' => 'view',749 'title' => __( 'View User' ),750 'href' => $view_link,751 ) 752 );735 } elseif ( 'term' == $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) { 736 $tax = get_taxonomy( $tag->taxonomy ); 737 if ( is_taxonomy_viewable( $tax ) ) { 738 $wp_admin_bar->add_menu( 739 array( 740 'id' => 'view', 741 'title' => $tax->labels->view_item, 742 'href' => get_term_link( $tag ), 743 ) 744 ); 745 } 746 } elseif ( 'user-edit' == $current_screen->base && isset( $user_id ) ) { 747 $user_object = get_userdata( $user_id ); 748 $view_link = get_author_posts_url( $user_object->ID ); 749 if ( $user_object->exists() && $view_link ) { 750 $wp_admin_bar->add_menu( 751 array( 752 'id' => 'view', 753 'title' => __( 'View User' ), 754 'href' => $view_link, 755 ) 756 ); 757 } 753 758 } 754 759 } else { … … 759 764 } 760 765 761 if ( ! empty( $current_object->post_type ) 762 && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) 763 && current_user_can( 'edit_post', $current_object->ID ) 764 && $post_type_object->show_in_admin_bar 765 && $edit_post_link = get_edit_post_link( $current_object->ID ) ) { 766 $wp_admin_bar->add_menu( 767 array( 768 'id' => 'edit', 769 'title' => $post_type_object->labels->edit_item, 770 'href' => $edit_post_link, 771 ) 772 ); 773 } elseif ( ! empty( $current_object->taxonomy ) 774 && ( $tax = get_taxonomy( $current_object->taxonomy ) ) 775 && current_user_can( 'edit_term', $current_object->term_id ) 776 && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) { 777 $wp_admin_bar->add_menu( 778 array( 779 'id' => 'edit', 780 'title' => $tax->labels->edit_item, 781 'href' => $edit_term_link, 782 ) 783 ); 784 } elseif ( is_a( $current_object, 'WP_User' ) 785 && current_user_can( 'edit_user', $current_object->ID ) 786 && $edit_user_link = get_edit_user_link( $current_object->ID ) ) { 787 $wp_admin_bar->add_menu( 788 array( 789 'id' => 'edit', 790 'title' => __( 'Edit User' ), 791 'href' => $edit_user_link, 792 ) 793 ); 766 if ( ! empty( $current_object->post_type ) ) { 767 $post_type_object = get_post_type_object( $current_object->post_type ); 768 $edit_post_link = get_edit_post_link( $current_object->ID ); 769 if ( $post_type_object 770 && $edit_post_link 771 && current_user_can( 'edit_post', $current_object->ID ) 772 && $post_type_object->show_in_admin_bar ) { 773 $wp_admin_bar->add_menu( 774 array( 775 'id' => 'edit', 776 'title' => $post_type_object->labels->edit_item, 777 'href' => $edit_post_link, 778 ) 779 ); 780 } 781 } elseif ( ! empty( $current_object->taxonomy ) ) { 782 $tax = get_taxonomy( $current_object->taxonomy ); 783 $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ); 784 if ( $tax && $edit_term_link && current_user_can( 'edit_term', $current_object->term_id ) ) { 785 $wp_admin_bar->add_menu( 786 array( 787 'id' => 'edit', 788 'title' => $tax->labels->edit_item, 789 'href' => $edit_term_link, 790 ) 791 ); 792 } 793 } elseif ( is_a( $current_object, 'WP_User' ) && current_user_can( 'edit_user', $current_object->ID ) ) { 794 $edit_user_link = get_edit_user_link( $current_object->ID ); 795 if ( $edit_user_link ) { 796 $wp_admin_bar->add_menu( 797 array( 798 'id' => 'edit', 799 'title' => __( 'Edit User' ), 800 'href' => $edit_user_link, 801 ) 802 ); 803 } 794 804 } 795 805 }
Note: See TracChangeset
for help on using the changeset viewer.