WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#12270 closed defect (bug) (fixed)

Incorrect menu active for edit custom taxonomy form

Reported by: jfarthing84 Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description

When using edit-tag-form.php for a custom taxonomy, the correct menu is not highlighted. This is because the variables $parent_file and $submenu_file are not set or not correctly set. The "Edit" links within the tag row actions will need to be updated to include "post_type" as it is needed to point to the correct parent_file and submenu_file for the custom taxonomy menu.

Change History (8)

comment:1 @scribu5 years ago

  • Milestone changed from Unassigned to 3.0

comment:2 @dd325 years ago

When using edit-tag-form.php for a custom taxonomy, the correct menu is not highlighted. This is because the variables $parent_file and $submenu_file are not set or not correctly set.

Thats worked for me in core for quite awhile now. See #11838 which is related.

The "Edit" links within the tag row actions will need to be updated to include "post_type" as it is needed to point to the correct parent_file and submenu_file for the custom taxonomy menu.

Thats still a problem AFAIK, and needs to be updated as you suggest

comment:3 @jfarthing845 years ago

I'm not sure you understood. Let's say I have a custom post type "movie". Within that product I have a few taxonomies: "actor", "director", "writer", etc.

Now, when I visit "edit-tags.php?taxonomy=actor&post_type=movie" (which is the default menu created by WP), the correct menu item is highlighted ("Movies") along with the correct sub-menu ("Actors"). However, click the edit link for a specific term (i.e. "edit-tags.php?action=edit&taxonomy=actor" and then the "Posts" menu is highlighted with no submenu highlighted.

This is due to no post_type being passed with the edit link, because the post_type is included in the key for the submenu. Same with the menu.

comment:4 @jfarthing845 years ago

if ( empty($post_type) || !in_array( $post_type, get_post_types( array('show_ui' => true) ) ) )
	$post_type = 'post';

if ( 'post' != $post_type ) {
	$parent_file = "edit.php?post_type=$post_type";
	$submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
} else {
	$parent_file = 'edit.php';
	$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
}

Because of that, when editing a term, the post_type is always post because the post_type is not passed via the query. So, $parent_file will always evaluate to 'edit.php' and $submenu_file to 'edit-tags.php?taxonomy=$taxonomy', thus highlighting the incorrect menus.

comment:5 @dd325 years ago

Ah, Now thats clearer. Yes, When editing a term, Its defaulting to the post menu.

comment:6 @dd325 years ago

(In [13213]) 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

comment:7 @dd325 years ago

That commit should fix it. Re-open if you've still got any issues.

comment:8 @nacin5 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.