diff --git a/wp-admin/includes/default-list-tables.php b/wp-admin/includes/default-list-tables.php index 1b233d455e..355a96a98d 100644 --- a/wp-admin/includes/default-list-tables.php +++ b/wp-admin/includes/default-list-tables.php @@ -1654,7 +1654,7 @@ class WP_Terms_Table extends WP_List_Table { $pad = str_repeat( '— ', max( 0, $this->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&post_type=$post_type&tag_ID=$tag->term_id"; + $edit_link = get_edit_term_url( $tag->term_id, $taxonomy, $post_type ); $out = '' . $name . '
'; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index b505487265..c5f2005318 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -649,9 +649,10 @@ function get_tag_feed_link($tag_id, $feed = '') { * @since 2.7.0 * * @param int $tag_id Tag ID + * @param string $taxonomy Taxonomy * @return string */ -function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { +function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { return apply_filters( 'get_edit_tag_link', get_edit_term_url( $tag_id, $taxonomy ) ); } @@ -677,19 +678,29 @@ function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { * @since 3.1 * * @param int $term_id Term ID - * @param int $taxonomy Taxonomy + * @param string $taxonomy Taxonomy + * @param string $object_type The object type * @return string */ -function get_edit_term_url( $term_id = 0, $taxonomy = 'post_tag' ) { - $tax = get_taxonomy($taxonomy); - if ( !current_user_can($tax->cap->edit_terms) ) +function get_edit_term_url( $term_id, $taxonomy, $object_type = '' ) { + $tax = get_taxonomy( $taxonomy ); + if ( !current_user_can( $tax->cap->edit_terms ) ) return; - $term = get_term($term_id, $taxonomy); + $term = get_term( $term_id, $taxonomy ); - $location = admin_url('edit-tags.php?action=edit&taxonomy=' . $taxonomy .'&tag_ID=' . $term->term_id); + $args = array( + 'action' => 'edit', + 'taxonomy' => $taxonomy, + 'tag_ID' => $term->term_id, + ); - return apply_filters( 'get_edit_term_url', $location ); + if ( $object_type ) + $args['post_type'] = $object_type; + + $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); + + return apply_filters( 'get_edit_term_url', $location, $term_id, $taxonomy, $object_type ); } /** @@ -704,22 +715,21 @@ function get_edit_term_url( $term_id = 0, $taxonomy = 'post_tag' ) { * @return string HTML content. */ function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { - - if ( $term == null ) { + if ( is_null( $term ) ) { global $wp_query; $term = $wp_query->get_queried_object(); } - + $tax = get_taxonomy( $term->taxonomy ); if ( !current_user_can($tax->cap->edit_terms) ) return; - if ( empty($link) ) + if ( empty( $link ) ) $link = __('Edit This'); $link = '' . $link . ''; $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; - + if ( $echo ) echo $link; else