Skip to content

Commit

Permalink
Fix $post_type handling/passing in the Taxonomy edit links. Fix the T…
Browse files Browse the repository at this point in the history
…ag selection query var for edit.php in the Posts links. See #12270, See #11838

git-svn-id: http://svn.automattic.com/wordpress/trunk@13213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
dd32 committed Feb 19, 2010
1 parent ce0590b commit 8c26cff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
37 changes: 26 additions & 11 deletions wp-admin/edit-tags.php
Expand Up @@ -45,17 +45,33 @@
wp_die(__('Cheatin’ uh?'));

$ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
if ( $ret && !is_wp_error( $ret ) ) {
wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=1#addtag");
} else {
wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=4#addtag");
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;

if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos($referer, 'edit-tags.php') )
$location = $referer;
}

if ( $ret && !is_wp_error( $ret ) )
$location = add_query_arg('message', 1, $location);
else
$location = add_query_arg('message', 4, $location);
exit;
break;

case 'delete':
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos($referer, 'edit-tags.php') )
$location = $referer;
}

if ( !isset( $_GET['tag_ID'] ) ) {
wp_redirect("edit-tags.php?taxonomy=$taxonomy");
wp_redirect($location);
exit;
}

Expand All @@ -67,12 +83,6 @@

wp_delete_term( $tag_ID, $taxonomy);

$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos($referer, 'edit-tags.php') )
$location = $referer;
}

$location = add_query_arg('message', 2, $location);
wp_redirect($location);
exit;
Expand All @@ -91,6 +101,8 @@
}

$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos($referer, 'edit-tags.php') )
$location = $referer;
Expand Down Expand Up @@ -123,6 +135,9 @@
$ret = wp_update_term($tag_ID, $taxonomy, $_POST);

$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;

if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos($referer, 'edit-tags.php') )
$location = $referer;
Expand Down
23 changes: 14 additions & 9 deletions wp-admin/includes/template.php
Expand Up @@ -452,25 +452,29 @@ function wp_link_category_checklist( $link_id = 0 ) {
* @return unknown
*/
function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
global $post_type;
static $row_class = '';
$row_class = ($row_class == '' ? ' class="alternate"' : '');

$count = number_format_i18n( $tag->count );
if ( 'post_tag' == $taxonomy )
$tax = get_taxonomy($taxonomy);

if ( 'post_tag' == $taxonomy ) {
$tagsel = 'tag';
elseif ( 'category' == $taxonomy )
} elseif ( 'category' == $taxonomy ) {
$tagsel = 'category_name';
else
} elseif ( ! empty($tax->query_var) ) {
$tagsel = $tax->query_var;
} else {
$tagsel = $taxonomy;
}

$tax = get_taxonomy($taxonomy);

$count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count;
$count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug&amp;post_type=$post_type'>$count</a>" : $count;

$pad = str_repeat( '&#8212; ', max(0, $level) );
$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
$qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
$edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id";
$edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;post_type=$post_type&amp;tag_ID=$tag->term_id";

$out = '';
$out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
Expand Down Expand Up @@ -586,6 +590,7 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'po
$terms = get_terms( $taxonomy, $args );
foreach( $terms as $term )
$out .= _tag_row( $term, 0, $taxonomy );
$count = $pagesize; // Only displaying a single page.
}

echo $out;
Expand Down Expand Up @@ -3283,7 +3288,7 @@ function find_posts_div($found_action = '') {
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
<input type="text" id="find-posts-input" name="ps" value="" />
<input type="button" onClick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
<input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />

<input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
<label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
Expand All @@ -3293,7 +3298,7 @@ function find_posts_div($found_action = '') {
<div id="find-posts-response"></div>
</div>
<div class="find-box-buttons">
<input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
<input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
<input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions wp-includes/link-template.php
Expand Up @@ -619,13 +619,14 @@ function get_tag_feed_link($tag_id, $feed = '') {
* @return string
*/
function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) {
global $post_type;
$tax = get_taxonomy($taxonomy);
if ( !current_user_can($tax->edit_cap) )
return;

$tag = get_term($tag_id, $taxonomy);

$location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;tag_ID=' . $tag->term_id);
$location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;' . (!empty($post_type) ? 'post_type=' . $post_type .'&amp;' : '') .'tag_ID=' . $tag->term_id);
return apply_filters( 'get_edit_tag_link', $location );
}

Expand Down

0 comments on commit 8c26cff

Please sign in to comment.