Make WordPress Core

Ticket #17705: 17705.diff

File 17705.diff, 6.2 KB (added by nacin, 14 years ago)
  • wp-includes/admin-bar.php

     
    8989
    9090                /* Add the "My Account" sub menus */
    9191                $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() ) );
    9692                $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) );
    9793        }
    9894}
    9995
    10096/**
     97 * Add the "Dashboard"/"View Site" menu.
     98 *
     99 * @since 3.2.0
     100 */
     101function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
     102        if ( is_admin() )
     103                $wp_admin_bar->add_menu( array( 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
     104        elseif ( is_multisite() )
     105                $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( get_current_user_id() ) ) );
     106        else
     107                $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
     108}
     109
     110/**
    101111 * Add the "My Sites/[Site Name]" menu and all submenus.
    102112 *
    103113 * @since 3.1.0
     
    160170 * @since 3.1.0
    161171 */
    162172function wp_admin_bar_edit_menu( $wp_admin_bar ) {
    163         $current_object = get_queried_object();
     173        global $post, $tag;
    164174
    165         if ( empty($current_object) )
    166                 return;
     175        if ( is_admin() ) {
     176                $current_screen = get_current_screen();
    167177
    168         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 || 'attachment' == $current_object->post_type ) ) {
    169                 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item,  'href' => get_edit_post_link( $current_object->ID ) ) );
    170         } elseif ( ! empty( $current_object->taxonomy ) &&  ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) {
    171                 $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 ) ) );
     178                if ( 'post' == $current_screen->base
     179                        && 'add' != $current_screen->action
     180                        && ( $post_type_object = get_post_type_object( $post->post_type ) )
     181                        && current_user_can( $post_type_object->cap->read_post, $post->ID )
     182                        && ( $post_type_object->public ) )
     183                {
     184                        $wp_admin_bar->add_menu( array(
     185                                'id' => 'view',
     186                                'title' => $post_type_object->labels->view_item,
     187                                'href' => get_permalink( $post->ID )
     188                        ) );
     189                } elseif ( 'edit-tags' == $current_screen->base
     190                        && isset( $tag ) && is_object( $tag )
     191                        && ( $tax = get_taxonomy( $tag->taxonomy ) )
     192                        && $tax->public )
     193                {
     194                        $wp_admin_bar->add_menu( array(
     195                                'id' => 'view',
     196                                'title' => $tax->labels->view_item,
     197                                'href' => get_term_link( $tag )
     198                        ) );
     199                }
     200        } else {
     201                $current_object = get_queried_object();
     202
     203                if ( empty($current_object) )
     204                        return;
     205
     206                if ( ! empty( $current_object->post_type )
     207                        && ( $post_type_object = get_post_type_object( $current_object->post_type ) )
     208                        && current_user_can( $post_type_object->cap->edit_post, $current_object->ID )
     209                        && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) )
     210                {
     211                        $wp_admin_bar->add_menu( array(
     212                                'id' => 'edit',
     213                                'title' => $post_type_object->labels->edit_item,
     214                                'href' => get_edit_post_link( $current_object->ID )
     215                        ) );
     216                } elseif ( ! empty( $current_object->taxonomy )
     217                        && ( $tax = get_taxonomy( $current_object->taxonomy ) )
     218                        && current_user_can( $tax->cap->edit_terms )
     219                        && $tax->show_ui )
     220                {
     221                        $wp_admin_bar->add_menu( array(
     222                                'id' => 'edit',
     223                                'title' => $tax->labels->edit_item,
     224                                'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy )
     225                        ) );
     226                }
    172227        }
    173228}
    174229
  • wp-includes/taxonomy.php

     
    404404                'parent_item' => array( null, __( 'Parent Category' ) ),
    405405                'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
    406406                'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
     407                'view_item' => array( __( 'View Tag' ), __( 'View Category' ) ),
    407408                'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
    408409                'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
    409410                'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
  • wp-includes/class-wp-admin-bar.php

     
    180180
    181181        function add_menus() {
    182182                add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 10 );
     183                add_action( 'admin_bar_menu', 'wp_admin_bar_dashboard_view_site_menu', 15 );
    183184                add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
    184185                add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 30 );
    185186                add_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 );
  • wp-admin/includes/class-wp-terms-list-table.php

     
    261261                }
    262262                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    263263                        $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
     264                $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
    264265
    265266                $actions = apply_filters( 'tag_row_actions', $actions, $tag );
    266267                $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );