Fix $post_type handling/passing in the Taxonomy edit links. Fix the Tag 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
This commit is contained in:
parent
ce0590be8c
commit
8c26cffe1b
|
@ -45,17 +45,33 @@ case 'add-tag':
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -67,12 +83,6 @@ case 'delete':
|
|||
|
||||
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;
|
||||
|
@ -91,6 +101,8 @@ case 'bulk-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;
|
||||
|
@ -123,6 +135,9 @@ case 'editedtag':
|
|||
$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;
|
||||
|
|
|
@ -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 )
|
||||
$tagsel = 'tag';
|
||||
elseif ( 'category' == $taxonomy )
|
||||
$tagsel = 'category_name';
|
||||
else
|
||||
$tagsel = $taxonomy;
|
||||
|
||||
$tax = get_taxonomy($taxonomy);
|
||||
|
||||
$count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count;
|
||||
if ( 'post_tag' == $taxonomy ) {
|
||||
$tagsel = 'tag';
|
||||
} elseif ( 'category' == $taxonomy ) {
|
||||
$tagsel = 'category_name';
|
||||
} elseif ( ! empty($tax->query_var) ) {
|
||||
$tagsel = $tax->query_var;
|
||||
} else {
|
||||
$tagsel = $taxonomy;
|
||||
}
|
||||
|
||||
$count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug&post_type=$post_type'>$count</a>" : $count;
|
||||
|
||||
$pad = str_repeat( '— ', 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&taxonomy=$taxonomy&tag_ID=$tag->term_id";
|
||||
$edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&post_type=$post_type&tag_ID=$tag->term_id";
|
||||
|
||||
$out = '';
|
||||
$out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
|
|
@ -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&taxonomy=' . $taxonomy . '&tag_ID=' . $tag->term_id);
|
||||
$location = admin_url('edit-tags.php?action=edit&taxonomy=' . $taxonomy . '&' . (!empty($post_type) ? 'post_type=' . $post_type .'&' : '') .'tag_ID=' . $tag->term_id);
|
||||
return apply_filters( 'get_edit_tag_link', $location );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue