<!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-&gt;cap-&gt;delete_terms ) &amp;&amp; $tag-&gt;term_id != $default_term )
</span><span class="cx">                         $actions['delete'] = &quot;&lt;a class='delete-tag' href='&quot; . wp_nonce_url( &quot;edit-tags.php?action=delete&amp;amp;taxonomy=$taxonomy&amp;amp;tag_ID=$tag-&gt;term_id&quot;, 'delete-tag_' . $tag-&gt;term_id ) . &quot;'&gt;&quot; . __( 'Delete' ) . &quot;&lt;/a&gt;&quot;;
</span><ins>+                $actions['view'] = '&lt;a href=&quot;' . get_term_link( $tag ) . '&quot;&gt;' . __( 'View' ) . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><span class="cx">                 $actions = apply_filters( 'tag_row_actions', $actions, $tag );
</span><span class="cx">                 $actions = apply_filters( &quot;{$taxonomy}_row_actions&quot;, $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 &quot;My Account&quot; sub menus */
</span><span class="cx">                 $wp_admin_bar-&gt;add_menu( array( 'parent' =&gt; $id, 'title' =&gt; __( 'Edit My Profile' ), 'href' =&gt; get_edit_profile_url( $user_id ) ) );
</span><del>-                if ( is_multisite() )
-                        $wp_admin_bar-&gt;add_menu( array( 'parent' =&gt; $id, 'title' =&gt; __( 'Dashboard' ), 'href' =&gt; get_dashboard_url( $user_id ) ) );
-                else
-                        $wp_admin_bar-&gt;add_menu( array( 'parent' =&gt; $id, 'title' =&gt; __( 'Dashboard' ), 'href' =&gt; admin_url() ) );
</del><span class="cx">                 $wp_admin_bar-&gt;add_menu( array( 'parent' =&gt; $id, 'title' =&gt; __( 'Log Out' ), 'href' =&gt; wp_logout_url() ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Add the &quot;Dashboard&quot;/&quot;View Site&quot; menu.
+ *
+ * @since 3.2.0
+ */
+function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
+        if ( is_admin() )
+                $wp_admin_bar-&gt;add_menu( array( 'title' =&gt; __( 'Visit Site' ), 'href' =&gt; home_url() ) );
+        elseif ( is_multisite() )
+                $wp_admin_bar-&gt;add_menu( array( 'title' =&gt; __( 'Dashboard' ), 'href' =&gt; get_dashboard_url( get_current_user_id() ) ) );
+        else
+                $wp_admin_bar-&gt;add_menu( array( 'title' =&gt; __( 'Dashboard' ), 'href' =&gt; admin_url() ) );
+}
+
+/**
</ins><span class="cx">  * Add the &quot;My Sites/[Site Name]&quot; 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-&gt;post_type ) &amp;&amp; ( $post_type_object = get_post_type_object( $current_object-&gt;post_type ) ) &amp;&amp; current_user_can( $post_type_object-&gt;cap-&gt;edit_post, $current_object-&gt;ID ) &amp;&amp; ( $post_type_object-&gt;show_ui || 'attachment' == $current_object-&gt;post_type ) ) {
-                $wp_admin_bar-&gt;add_menu( array( 'id' =&gt; 'edit', 'title' =&gt; $post_type_object-&gt;labels-&gt;edit_item,  'href' =&gt; get_edit_post_link( $current_object-&gt;ID ) ) );
-        } elseif ( ! empty( $current_object-&gt;taxonomy ) &amp;&amp;  ( $tax = get_taxonomy( $current_object-&gt;taxonomy ) ) &amp;&amp; current_user_can( $tax-&gt;cap-&gt;edit_terms ) &amp;&amp; $tax-&gt;show_ui ) {
-                $wp_admin_bar-&gt;add_menu( array( 'id' =&gt; 'edit', 'title' =&gt; $tax-&gt;labels-&gt;edit_item, 'href' =&gt; get_edit_term_link( $current_object-&gt;term_id, $current_object-&gt;taxonomy ) ) );
</del><ins>+                if ( 'post' == $current_screen-&gt;base
+                        &amp;&amp; 'add' != $current_screen-&gt;action
+                        &amp;&amp; ( $post_type_object = get_post_type_object( $post-&gt;post_type ) )
+                        &amp;&amp; current_user_can( $post_type_object-&gt;cap-&gt;read_post, $post-&gt;ID )
+                        &amp;&amp; ( $post_type_object-&gt;public ) )
+                {
+                        $wp_admin_bar-&gt;add_menu( array(
+                                'id' =&gt; 'view',
+                                'title' =&gt; $post_type_object-&gt;labels-&gt;view_item,
+                                'href' =&gt; get_permalink( $post-&gt;ID )
+                        ) );
+                } elseif ( 'edit-tags' == $current_screen-&gt;base
+                        &amp;&amp; isset( $tag ) &amp;&amp; is_object( $tag )
+                        &amp;&amp; ( $tax = get_taxonomy( $tag-&gt;taxonomy ) )
+                        &amp;&amp; $tax-&gt;public )
+                {
+                        $wp_admin_bar-&gt;add_menu( array(
+                                'id' =&gt; 'view',
+                                'title' =&gt; $tax-&gt;labels-&gt;view_item,
+                                'href' =&gt; get_term_link( $tag )
+                        ) );
+                }
+        } else {
+                $current_object = get_queried_object();
+
+                if ( empty($current_object) )
+                        return;
+
+                if ( ! empty( $current_object-&gt;post_type )
+                        &amp;&amp; ( $post_type_object = get_post_type_object( $current_object-&gt;post_type ) )
+                        &amp;&amp; current_user_can( $post_type_object-&gt;cap-&gt;edit_post, $current_object-&gt;ID )
+                        &amp;&amp; ( $post_type_object-&gt;show_ui || 'attachment' == $current_object-&gt;post_type ) )
+                {
+                        $wp_admin_bar-&gt;add_menu( array(
+                                'id' =&gt; 'edit',
+                                'title' =&gt; $post_type_object-&gt;labels-&gt;edit_item,
+                                'href' =&gt; get_edit_post_link( $current_object-&gt;ID )
+                        ) );
+                } elseif ( ! empty( $current_object-&gt;taxonomy )
+                        &amp;&amp; ( $tax = get_taxonomy( $current_object-&gt;taxonomy ) )
+                        &amp;&amp; current_user_can( $tax-&gt;cap-&gt;edit_terms )
+                        &amp;&amp; $tax-&gt;show_ui )
+                {
+                        $wp_admin_bar-&gt;add_menu( array(
+                                'id' =&gt; 'edit',
+                                'title' =&gt; $tax-&gt;labels-&gt;edit_item,
+                                'href' =&gt; get_edit_term_link( $current_object-&gt;term_id, $current_object-&gt;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' =&gt; array( null, __( 'Parent Category' ) ),
</span><span class="cx">                 'parent_item_colon' =&gt; array( null, __( 'Parent Category:' ) ),
</span><span class="cx">                 'edit_item' =&gt; array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
</span><ins>+                'view_item' =&gt; array( __( 'View Tag' ), __( 'View Category' ) ),
</ins><span class="cx">                 'update_item' =&gt; array( __( 'Update Tag' ), __( 'Update Category' ) ),
</span><span class="cx">                 'add_new_item' =&gt; array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
</span><span class="cx">                 'new_item_name' =&gt; array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
</span></span></pre>
</div>
</div>

</body>
</html>