Make WordPress Core

Changeset 18194


Ignore:
Timestamp:
06/08/2011 04:49:27 PM (14 years ago)
Author:
nacin
Message:

Admin Bar: Add View Site/Dashboard links, 'View X' links in the admin, 'View' action link for terms. New custom taxonomy string: view_item, defaulting to 'View Tag' and View Category'. fixes #17705.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-terms-list-table.php

    r18010 r18194  
    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 );
  • trunk/wp-includes/admin-bar.php

    r18164 r18194  
    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    }
     94}
     95
     96/**
     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() ) );
    98108}
    99109
     
    161171 */
    162172function wp_admin_bar_edit_menu( $wp_admin_bar ) {
    163     $current_object = get_queried_object();
    164 
    165     if ( empty($current_object) )
    166         return;
    167 
    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 ) ) );
     173    global $post, $tag;
     174
     175    if ( is_admin() ) {
     176        $current_screen = get_current_screen();
     177
     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}
  • trunk/wp-includes/class-wp-admin-bar.php

    r17435 r18194  
    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 );
  • trunk/wp-includes/taxonomy.php

    r18128 r18194  
    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' ) ),
Note: See TracChangeset for help on using the changeset viewer.