<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[13213] trunk: Fix $post_type handling/passing in the Taxonomy edit links.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13213">13213</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-02-19 09:54:18 +0000 (Fri, 19 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix $post_type handling/passing in the Taxonomy edit links. Fix the Tag selection query var for edit.php in the Posts links. See <a href="http://trac.wordpress.org/ticket/12270">#12270</a>, See <a href="http://trac.wordpress.org/ticket/11838">#11838</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (13212 => 13213)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2010-02-19 09:33:50 UTC (rev 13212)
+++ trunk/wp-admin/edit-tags.php        2010-02-19 09:54:18 UTC (rev 13213)
</span><span class="lines">@@ -45,17 +45,33 @@
</span><span class="cx">                 wp_die(__('Cheatin&amp;#8217; uh?'));
</span><span class="cx"> 
</span><span class="cx">         $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
</span><del>-        if ( $ret &amp;&amp; !is_wp_error( $ret ) ) {
-                wp_redirect(&quot;edit-tags.php?taxonomy=$taxonomy&amp;amp;message=1#addtag&quot;);
-        } else {
-                wp_redirect(&quot;edit-tags.php?taxonomy=$taxonomy&amp;amp;message=4#addtag&quot;);
</del><ins>+        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
+        if ( 'post' != $post_type )
+                $location .= '&amp;post_type=' . $post_type;
+
+        if ( $referer = wp_get_original_referer() ) {
+                if ( false !== strpos($referer, 'edit-tags.php') )
+                        $location = $referer;
</ins><span class="cx">         }
</span><ins>+
+        if ( $ret &amp;&amp; !is_wp_error( $ret ) )
+                $location = add_query_arg('message', 1, $location);
+        else
+                $location = add_query_arg('message', 4, $location);
</ins><span class="cx">         exit;
</span><span class="cx"> break;
</span><span class="cx"> 
</span><span class="cx"> case 'delete':
</span><ins>+        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
+        if ( 'post' != $post_type )
+                $location .= '&amp;post_type=' . $post_type;
+        if ( $referer = wp_get_referer() ) {
+                if ( false !== strpos($referer, 'edit-tags.php') )
+                        $location = $referer;
+        }
+
</ins><span class="cx">         if ( !isset( $_GET['tag_ID'] ) ) {
</span><del>-                wp_redirect(&quot;edit-tags.php?taxonomy=$taxonomy&quot;);
</del><ins>+                wp_redirect($location);
</ins><span class="cx">                 exit;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -67,12 +83,6 @@
</span><span class="cx"> 
</span><span class="cx">         wp_delete_term( $tag_ID, $taxonomy);
</span><span class="cx"> 
</span><del>-        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
-        if ( $referer = wp_get_referer() ) {
-                if ( false !== strpos($referer, 'edit-tags.php') )
-                        $location = $referer;
-        }
-
</del><span class="cx">         $location = add_query_arg('message', 2, $location);
</span><span class="cx">         wp_redirect($location);
</span><span class="cx">         exit;
</span><span class="lines">@@ -91,6 +101,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $location = 'edit-tags.php?taxonomy=' . $taxonomy;
</span><ins>+        if ( 'post' != $post_type )
+                $location .= '&amp;post_type=' . $post_type;
</ins><span class="cx">         if ( $referer = wp_get_referer() ) {
</span><span class="cx">                 if ( false !== strpos($referer, 'edit-tags.php') )
</span><span class="cx">                         $location = $referer;
</span><span class="lines">@@ -123,6 +135,9 @@
</span><span class="cx">         $ret = wp_update_term($tag_ID, $taxonomy, $_POST);
</span><span class="cx"> 
</span><span class="cx">         $location = 'edit-tags.php?taxonomy=' . $taxonomy;
</span><ins>+        if ( 'post' != $post_type )
+                $location .= '&amp;post_type=' . $post_type;
+
</ins><span class="cx">         if ( $referer = wp_get_original_referer() ) {
</span><span class="cx">                 if ( false !== strpos($referer, 'edit-tags.php') )
</span><span class="cx">                         $location = $referer;
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (13212 => 13213)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-02-19 09:33:50 UTC (rev 13212)
+++ trunk/wp-admin/includes/template.php        2010-02-19 09:54:18 UTC (rev 13213)
</span><span class="lines">@@ -452,25 +452,29 @@
</span><span class="cx">  * @return unknown
</span><span class="cx">  */
</span><span class="cx"> function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
</span><ins>+                global $post_type;
</ins><span class="cx">                 static $row_class = '';
</span><span class="cx">                 $row_class = ($row_class == '' ? ' class=&quot;alternate&quot;' : '');
</span><span class="cx"> 
</span><span class="cx">                 $count = number_format_i18n( $tag-&gt;count );
</span><del>-                if ( 'post_tag' == $taxonomy )
</del><ins>+                $tax = get_taxonomy($taxonomy);
+
+                if ( 'post_tag' == $taxonomy ) {
</ins><span class="cx">                         $tagsel = 'tag';
</span><del>-                elseif ( 'category' == $taxonomy )
</del><ins>+                } elseif ( 'category' == $taxonomy ) {
</ins><span class="cx">                         $tagsel = 'category_name';
</span><del>-                else
</del><ins>+                } elseif ( ! empty($tax-&gt;query_var) ) {
+                        $tagsel = $tax-&gt;query_var;
+                } else {
</ins><span class="cx">                         $tagsel = $taxonomy;
</span><ins>+                }
</ins><span class="cx"> 
</span><del>-                $tax = get_taxonomy($taxonomy);
</del><ins>+                $count = ( $count &gt; 0 ) ? &quot;&lt;a href='edit.php?$tagsel=$tag-&gt;slug&amp;amp;post_type=$post_type'&gt;$count&lt;/a&gt;&quot; : $count;
</ins><span class="cx"> 
</span><del>-                $count = ( $count &gt; 0 ) ? &quot;&lt;a href='edit.php?$tagsel=$tag-&gt;slug'&gt;$count&lt;/a&gt;&quot; : $count;
-
</del><span class="cx">                 $pad = str_repeat( '&amp;#8212; ', max(0, $level) );
</span><span class="cx">                 $name = apply_filters( 'term_name', $pad . ' ' . $tag-&gt;name, $tag );
</span><span class="cx">                 $qe_data = get_term($tag-&gt;term_id, $taxonomy, object, 'edit');
</span><del>-                $edit_link = &quot;edit-tags.php?action=edit&amp;amp;taxonomy=$taxonomy&amp;amp;tag_ID=$tag-&gt;term_id&quot;;
</del><ins>+                $edit_link = &quot;edit-tags.php?action=edit&amp;amp;taxonomy=$taxonomy&amp;amp;post_type=$post_type&amp;amp;tag_ID=$tag-&gt;term_id&quot;;
</ins><span class="cx"> 
</span><span class="cx">                 $out = '';
</span><span class="cx">                 $out .= '&lt;tr id=&quot;tag-' . $tag-&gt;term_id . '&quot;' . $row_class . '&gt;';
</span><span class="lines">@@ -586,6 +590,7 @@
</span><span class="cx">                 $terms = get_terms( $taxonomy, $args );
</span><span class="cx">                 foreach( $terms as $term )
</span><span class="cx">                         $out .= _tag_row( $term, 0, $taxonomy );
</span><ins>+                $count = $pagesize; // Only displaying a single page.
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         echo $out;
</span><span class="lines">@@ -3283,7 +3288,7 @@
</span><span class="cx">                                 &lt;?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?&gt;
</span><span class="cx">                                 &lt;label class=&quot;screen-reader-text&quot; for=&quot;find-posts-input&quot;&gt;&lt;?php _e( 'Search' ); ?&gt;&lt;/label&gt;
</span><span class="cx">                                 &lt;input type=&quot;text&quot; id=&quot;find-posts-input&quot; name=&quot;ps&quot; value=&quot;&quot; /&gt;
</span><del>-                                &lt;input type=&quot;button&quot; onClick=&quot;findPosts.send();&quot; value=&quot;&lt;?php esc_attr_e( 'Search' ); ?&gt;&quot; class=&quot;button&quot; /&gt;&lt;br /&gt;
</del><ins>+                                &lt;input type=&quot;button&quot; onclick=&quot;findPosts.send();&quot; value=&quot;&lt;?php esc_attr_e( 'Search' ); ?&gt;&quot; class=&quot;button&quot; /&gt;&lt;br /&gt;
</ins><span class="cx"> 
</span><span class="cx">                                 &lt;input type=&quot;radio&quot; name=&quot;find-posts-what&quot; id=&quot;find-posts-posts&quot; checked=&quot;checked&quot; value=&quot;posts&quot; /&gt;
</span><span class="cx">                                 &lt;label for=&quot;find-posts-posts&quot;&gt;&lt;?php _e( 'Posts' ); ?&gt;&lt;/label&gt;
</span><span class="lines">@@ -3293,7 +3298,7 @@
</span><span class="cx">                         &lt;div id=&quot;find-posts-response&quot;&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx">                 &lt;div class=&quot;find-box-buttons&quot;&gt;
</span><del>-                        &lt;input type=&quot;button&quot; class=&quot;button alignleft&quot; onClick=&quot;findPosts.close();&quot; value=&quot;&lt;?php esc_attr_e('Close'); ?&gt;&quot; /&gt;
</del><ins>+                        &lt;input type=&quot;button&quot; class=&quot;button alignleft&quot; onclick=&quot;findPosts.close();&quot; value=&quot;&lt;?php esc_attr_e('Close'); ?&gt;&quot; /&gt;
</ins><span class="cx">                         &lt;input id=&quot;find-posts-submit&quot; type=&quot;submit&quot; class=&quot;button-primary alignright&quot; value=&quot;&lt;?php esc_attr_e('Select'); ?&gt;&quot; /&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx">         &lt;/div&gt;
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (13212 => 13213)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-02-19 09:33:50 UTC (rev 13212)
+++ trunk/wp-includes/link-template.php        2010-02-19 09:54:18 UTC (rev 13213)
</span><span class="lines">@@ -619,13 +619,14 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) {
</span><ins>+        global $post_type;
</ins><span class="cx">         $tax = get_taxonomy($taxonomy);
</span><span class="cx">         if ( !current_user_can($tax-&gt;edit_cap) )
</span><span class="cx">                 return;
</span><del>-        
</del><ins>+
</ins><span class="cx">         $tag = get_term($tag_id, $taxonomy);
</span><span class="cx"> 
</span><del>-        $location = admin_url('edit-tags.php?action=edit&amp;amp;taxonomy=' . $taxonomy . '&amp;amp;tag_ID=' . $tag-&gt;term_id);
</del><ins>+        $location = admin_url('edit-tags.php?action=edit&amp;amp;taxonomy=' . $taxonomy . '&amp;amp;' . (!empty($post_type) ? 'post_type=' . $post_type .'&amp;amp;' : '') .'tag_ID=' . $tag-&gt;term_id);
</ins><span class="cx">         return apply_filters( 'get_edit_tag_link', $location );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>