From 3a51ff4d2e4452afa5ea04890c004f8692f68437 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 7 Mar 2016 12:55:04 +0000 Subject: [PATCH] Taxonomy: Improve backward compatibility on the `wp-admin/term.php` page. Specifically, run `do_action( 'edit-tags.php' );` on this new term edit page introduced in [36308]. Changes the GET param back to `tag_ID` and properly sets the screen base in `WP_Screen`. See #34988. git-svn-id: https://develop.svn.wordpress.org/trunk@36874 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/admin.php | 2 ++ src/wp-admin/includes/class-wp-screen.php | 2 ++ src/wp-admin/term.php | 6 +++--- src/wp-includes/admin-bar.php | 2 +- src/wp-includes/link-template.php | 2 +- tests/phpunit/tests/post.php | 2 +- tests/phpunit/tests/term/getEditTermLink.php | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/admin.php b/src/wp-admin/admin.php index 46977f9881..03426c18c2 100644 --- a/src/wp-admin/admin.php +++ b/src/wp-admin/admin.php @@ -355,6 +355,8 @@ if ( isset($plugin_page) ) { do_action( 'load-categories.php' ); elseif ( $taxnow == 'link_category' ) do_action( 'load-edit-link-categories.php' ); + } elseif( 'term.php' === $pagenow ) { + do_action( 'edit-tags.php' ); } } diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 5a02928710..ebd20b895a 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -304,6 +304,7 @@ final class WP_Screen { } break; case 'edit-tags' : + case 'term' : if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) $post_type = 'post'; break; @@ -322,6 +323,7 @@ final class WP_Screen { $id .= '-' . $post_type; break; case 'edit-tags' : + case 'term' : if ( null === $taxonomy ) $taxonomy = 'post_tag'; // The edit-tags ID does not contain the post type. Look for it in the request. diff --git a/src/wp-admin/term.php b/src/wp-admin/term.php index 6d00f50f02..5454874537 100644 --- a/src/wp-admin/term.php +++ b/src/wp-admin/term.php @@ -10,7 +10,7 @@ /** WordPress Administration Bootstrap */ require_once( dirname( __FILE__ ) . '/admin.php' ); -if ( empty( $_REQUEST['term_id'] ) ) { +if ( empty( $_REQUEST['tag_ID'] ) ) { $sendback = admin_url( 'edit-tags.php' ); if ( ! empty( $taxnow ) ) { $sendback = add_query_arg( array( 'taxonomy' => $taxnow ), $sendback ); @@ -19,8 +19,8 @@ if ( empty( $_REQUEST['term_id'] ) ) { exit; } -$term_id = absint( $_REQUEST['term_id'] ); -$tag = get_term( $term_id, $taxnow, OBJECT, 'edit' ); +$term_id = absint( $_REQUEST['tag_ID'] ); +$tag = get_term( $term_id, '', OBJECT, 'edit' ); if ( ! $tag instanceof WP_Term ) { wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 5bb2fcd97a..ab6d055955 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -573,7 +573,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) { 'href' => get_permalink( $post->ID ) ) ); } - } elseif ( 'edit-tags' == $current_screen->base + } elseif ( 'term' == $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) && ( $tax = get_taxonomy( $tag->taxonomy ) ) && $tax->public ) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 806481497f..a7ad29d18a 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -928,7 +928,7 @@ function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) { $args = array( 'taxonomy' => $taxonomy, - 'term_id' => $term->term_id, + 'tag_ID' => $term->term_id, ); if ( $object_type ) { diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 4f5a294643..a1ec373be8 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -991,7 +991,7 @@ class Tests_Post extends WP_UnitTestCase { $term = reset( $terms ); foreach ( $matches[1] as $url ) { - $this->assertContains( 'term_id=' . $term->term_id, $url ); + $this->assertContains( 'tag_ID=' . $term->term_id, $url ); $this->assertContains( 'post_type=new_post_type', $url ); } } diff --git a/tests/phpunit/tests/term/getEditTermLink.php b/tests/phpunit/tests/term/getEditTermLink.php index 54023271d7..c0844b932d 100644 --- a/tests/phpunit/tests/term/getEditTermLink.php +++ b/tests/phpunit/tests/term/getEditTermLink.php @@ -17,7 +17,7 @@ class Tests_Term_GetEditTermLink extends WP_UnitTestCase { ) ); $actual = get_edit_term_link( $term1, 'wptests_tax' ); - $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/term.php?taxonomy=wptests_tax&term_id=' . $term1 . '&post_type=post'; + $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/term.php?taxonomy=wptests_tax&tag_ID=' . $term1 . '&post_type=post'; $this->assertEquals( $expected, $actual ); }