Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#25566 closed defect (bug) (fixed)

Popular tags edit links do not respect current post type

Reported by: mordauk's profile mordauk Owned by: wonderboymusic's profile wonderboymusic
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.8
Component: Taxonomy Keywords: has-patch wcorl needs-testing
Focuses: administration Cc:

Description

When a post type registers a non-hierarchical taxonomy, there is a "Popular Tags" section displayed on that taxonomies overview. Each of the terms included in the popular tags Tag Cloud is linked to an edit page for that term, but when clicking on the edit link, the current post type isn't respected, meaning the admin menu goes from having the current post type highlighted to having the standard Posts menu highlighted.

For example, the URL for the edit link of a popular "Download Tag" from my Easy Digital Downloads plugin is:

/wp-admin/edit-tags.php?action=edit&taxonomy=download_tag&tag_ID=6

Since &post_type=download is not included in the URL, the dashboard menu highlight changes to Posts.

To fix this, a couple of things are needed:

  1. post_type needs to be passed as an argument to wp_tag_cloud() in wp-admin/edit-tags.php if the current user can edit the term.

2, The wp_tag_cloud() function should call get_edit_term_link() instead of get_edit_tag_link() when the link parameter is set to edit. The post_type arg passed should also be passed as the third parameter to get_edit_term_link(), for the object type.

Attachments (5)

25566.patch (1.7 KB) - added by mordauk 11 years ago.
25566.2.patch (2.1 KB) - added by mordauk 11 years ago.
Refreshed patch with documentation for the post_type argument of wp_tag_cloud
25566-test.diff (1.3 KB) - added by fahmiadib 11 years ago.
25566.diff (3.5 KB) - added by wonderboymusic 11 years ago.
25566.2.diff (3.6 KB) - added by wonderboymusic 11 years ago.

Download all attachments as: .zip

Change History (17)

@mordauk
11 years ago

#1 @mordauk
11 years ago

  • Keywords has-patch added
  • Version set to trunk

#2 @mordauk
11 years ago

  • Keywords wcorl added

#3 @mordauk
11 years ago

  • Keywords needs-testing added

#4 @mordauk
11 years ago

This is ready for further testing if anyone wants to tackle it.

#5 @DrewAPicture
11 years ago

  • Focuses administration added

25566.patch works as advertised for me. I also registered the taxonomy for multiple post types and both types the links respected the current post type.

Probably worth adding a short bit of documentation to the description about the new post_type parameter that wp_tag_cloud() accepts. We'll probably convert that section of the PHPDoc to a hash notation in the future but a small addition now should suffice.

@mordauk
11 years ago

Refreshed patch with documentation for the post_type argument of wp_tag_cloud

#6 @mordauk
11 years ago

Updated patch attached with documentation for the post_type argument.

#7 @DrewAPicture
11 years ago

  • Milestone changed from Awaiting Review to 3.9

25566.2.patch looks good to me.

#8 @fahmiadib
11 years ago

Added unit test. review?

#9 @wonderboymusic
11 years ago

25566.diff combines the patches - the unit tests need some work.

#10 @wonderboymusic
11 years ago

25566.2.diff contains safer unit tests

#11 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 27720:

Popular tags' edit links should respect the current post type. Adds unit test.

Props mordauk, fahmiadib.
Fixes #25566.

#12 @boonebgorges
9 years ago

In 35987:

More focused test for post_type in tag cloud links.

We should not be testing the entire tag cloud markup, as it leads to collateral
damage wheneven wp_generate_tag_cloud() is touched. See [35984].

See #25566, #35138.

Note: See TracTickets for help on using tickets.