Opened 10 years ago
Last modified 2 months ago
#38836 reviewing enhancement
A current_page_parent CSS class is not added to relevant WP menu items if the query is for a custom post type single item
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Menus | Keywords: | has-patch has-unit-tests good-first-bug |
| Focuses: | Cc: |
Description
A current_page_parent CSS class doesn't get added to relevant post type archive menu items if the current query is for a custom post type single item.
Attachments (3)
Change History (16)
#2
@
10 years ago
- Component changed from General to Menus
- Type changed from defect (bug) to enhancement
#4
@
10 years ago
- Keywords needs-unit-tests added
Patch looks ok to me. Let's get some unit test in place for it.
#5
@
10 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
38836.2.diff adds unit tests.
#6
@
7 years ago
- Keywords needs-refresh good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Version 4.6.1 deleted
The latest patch needs a refresh to apply cleanly.
@
7 years ago
Refreshed the patch. I've re-test the patch and re-run the unit tests as well. Everything looks good.
#9
@
7 years ago
- Milestone changed from Future Release to 5.3
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
This ticket was mentioned in Slack in #core by sergey. View the logs.
7 years ago
#11
@
7 years ago
@SergeyBiryukov The patch looks good and clean. Is this something we can include for 5.3 Beta 1 today? If not, feel free to update the milestone to whatever you think is realistic.
#12
@
7 years ago
- Milestone changed from 5.3 to Future Release
With version 5.3 Beta 1 releasing shortly, the deadline for enhancements is now passed. This is being moved to Future Release.
This ticket was mentioned in PR #11464 on WordPress/wordpress-develop by @iampi20.
2 months ago
#13
## Summary
When viewing a singular post of a public, non–built-in custom post type, the corresponding post type archive nav menu item did not receive the current_page_parent class, unlike the behavior users expect for “section” parents in menus.
This change:
- Precomputes public custom post types once in
_wp_menu_item_classes_by_context(). - On singular views of those types, adds
current_page_parentto matchingpost_type_archivemenu items (same post type inobject).
Refreshes the approach from older patches on the ticket and adds PHPUnit coverage.
## Testing
phpunit (filtered): Tests_Post_Nav_Menu — all tests passed locally.
Trac ticket: https://core.trac.wordpress.org/ticket/38836
## Use of AI Tools
AI assistance: Yes
Tool(s): Cursor (AI-assisted editor)
Used for: Guidance on contribution workflow, patch review, test structure, and PR text; implementation was applied in the local checkout, run through PHPUnit (Tests_Post_Nav_Menu), and reviewed by me before opening this PR.
Steps to reproduce
Note that the
current_page_parentCSS class isn't added to the menu item.