Fix the parent menu item field in REST API responses #34835
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
It looks like there was a small regression in #34673 which caused menu items to return a
parentof0. Theparentfield was switched to using thepost_parentinstead of themenu_item_parentfield. Switching it back seems to fix things.I'm not sure exactly what the difference between the two is. It looks like there's a little difference in how
wp_setup_nav_menu_itemhandles this value - https://github.com/WordPress/wordpress-develop/blob/c3ef52ded7bb480899adfd2f69d9e3fddd210615/src/wp-includes/nav-menu.php#L819I'll add some tests for this once #34765 has been tackled.
How has this been tested?
Expected: the menu should have the same structure as when it was saved.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.jsfiles for terms that need renaming or removal).