<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18194] trunk: Admin Bar: Add View Site/Dashboard links, 'View X' links in the admin, 'View' action link for terms.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/18194">18194</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2011-06-08 16:49:27 +0000 (Wed, 08 Jun 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <a href="http://trac.wordpress.org/ticket/17705">#17705</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswptermslisttablephp">trunk/wp-admin/includes/class-wp-terms-list-table.php</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludesclasswpadminbarphp">trunk/wp-includes/class-wp-admin-bar.php</a></li>
<li><a href="#trunkwpincludestaxonomyphp">trunk/wp-includes/taxonomy.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswptermslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-terms-list-table.php (18193 => 18194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-terms-list-table.php        2011-06-08 16:27:57 UTC (rev 18193)
+++ trunk/wp-admin/includes/class-wp-terms-list-table.php        2011-06-08 16:49:27 UTC (rev 18194)
</span><span class="lines">@@ -261,6 +261,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
</span><span class="cx">                         $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>";
</span><ins>+                $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
</ins><span class="cx">
</span><span class="cx">                 $actions = apply_filters( 'tag_row_actions', $actions, $tag );
</span><span class="cx">                 $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (18193 => 18194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2011-06-08 16:27:57 UTC (rev 18193)
+++ trunk/wp-includes/admin-bar.php        2011-06-08 16:49:27 UTC (rev 18194)
</span><span class="lines">@@ -89,15 +89,25 @@
</span><span class="cx">
</span><span class="cx">                 /* Add the "My Account" sub menus */
</span><span class="cx">                 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Edit My Profile' ), 'href' => get_edit_profile_url( $user_id ) ) );
</span><del>-                if ( is_multisite() )
-                        $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
-                else
-                        $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
</del><span class="cx">                 $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Add the "Dashboard"/"View Site" menu.
+ *
+ * @since 3.2.0
+ */
+function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
+        if ( is_admin() )
+                $wp_admin_bar->add_menu( array( 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
+        elseif ( is_multisite() )
+                $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( get_current_user_id() ) ) );
+        else
+                $wp_admin_bar->add_menu( array( 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
+}
+
+/**
</ins><span class="cx"> * Add the "My Sites/[Site Name]" menu and all submenus.
</span><span class="cx"> *
</span><span class="cx"> * @since 3.1.0
</span><span class="lines">@@ -160,15 +170,60 @@
</span><span class="cx"> * @since 3.1.0
</span><span class="cx"> */
</span><span class="cx"> function wp_admin_bar_edit_menu( $wp_admin_bar ) {
</span><del>-        $current_object = get_queried_object();
</del><ins>+        global $post, $tag;
</ins><span class="cx">
</span><del>-        if ( empty($current_object) )
-                return;
</del><ins>+        if ( is_admin() ) {
+                $current_screen = get_current_screen();
</ins><span class="cx">
</span><del>-        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 ) ) {
-                $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link( $current_object->ID ) ) );
-        } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) {
-                $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 ) ) );
</del><ins>+                if ( 'post' == $current_screen->base
+                        && 'add' != $current_screen->action
+                        && ( $post_type_object = get_post_type_object( $post->post_type ) )
+                        && current_user_can( $post_type_object->cap->read_post, $post->ID )
+                        && ( $post_type_object->public ) )
+                {
+                        $wp_admin_bar->add_menu( array(
+                                'id' => 'view',
+                                'title' => $post_type_object->labels->view_item,
+                                'href' => get_permalink( $post->ID )
+                        ) );
+                } elseif ( 'edit-tags' == $current_screen->base
+                        && isset( $tag ) && is_object( $tag )
+                        && ( $tax = get_taxonomy( $tag->taxonomy ) )
+                        && $tax->public )
+                {
+                        $wp_admin_bar->add_menu( array(
+                                'id' => 'view',
+                                'title' => $tax->labels->view_item,
+                                'href' => get_term_link( $tag )
+                        ) );
+                }
+        } else {
+                $current_object = get_queried_object();
+
+                if ( empty($current_object) )
+                        return;
+
+                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 ) )
+                {
+                        $wp_admin_bar->add_menu( array(
+                                'id' => 'edit',
+                                'title' => $post_type_object->labels->edit_item,
+                                'href' => get_edit_post_link( $current_object->ID )
+                        ) );
+                } elseif ( ! empty( $current_object->taxonomy )
+                        && ( $tax = get_taxonomy( $current_object->taxonomy ) )
+                        && current_user_can( $tax->cap->edit_terms )
+                        && $tax->show_ui )
+                {
+                        $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 )
+                        ) );
+                }
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesclasswpadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-admin-bar.php (18193 => 18194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-admin-bar.php        2011-06-08 16:27:57 UTC (rev 18193)
+++ trunk/wp-includes/class-wp-admin-bar.php        2011-06-08 16:49:27 UTC (rev 18194)
</span><span class="lines">@@ -180,6 +180,7 @@
</span><span class="cx">
</span><span class="cx">         function add_menus() {
</span><span class="cx">                 add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 10 );
</span><ins>+                add_action( 'admin_bar_menu', 'wp_admin_bar_dashboard_view_site_menu', 15 );
</ins><span class="cx">                 add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
</span><span class="cx">                 add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 30 );
</span><span class="cx">                 add_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 );
</span></span></pre></div>
<a id="trunkwpincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/taxonomy.php (18193 => 18194)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/taxonomy.php        2011-06-08 16:27:57 UTC (rev 18193)
+++ trunk/wp-includes/taxonomy.php        2011-06-08 16:49:27 UTC (rev 18194)
</span><span class="lines">@@ -404,6 +404,7 @@
</span><span class="cx">                 'parent_item' => array( null, __( 'Parent Category' ) ),
</span><span class="cx">                 'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
</span><span class="cx">                 'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
</span><ins>+                'view_item' => array( __( 'View Tag' ), __( 'View Category' ) ),
</ins><span class="cx">                 'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
</span><span class="cx">                 'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
</span><span class="cx">                 'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
</span></span></pre>
</div>
</div>
</body>
</html>