wp-cli / entity-command

Manage WordPress comments, menus, options, posts, sites, terms, and users.
MIT License
100 stars 90 forks source link

Fix position in menu item update #471

Closed ernilambar closed 7 months ago

ernilambar commented 8 months ago

Fixes https://github.com/wp-cli/entity-command/issues/463

Eg: wp menu item update 123 --position=2

ernilambar commented 8 months ago

@danielbachhuber Can you please review this approach of fixing menu item positions? I could not find a way without performing SQL query in loop. Any other alternative approach you have in mind? I will add Behat test after we finalize PHP code.

danielbachhuber commented 8 months ago

@ernilambar How does WordPress core do it?

ernilambar commented 8 months ago

@danielbachhuber Core does not have need to update separately. All data are fetched from $_POST and items are updated in loop. I also looked at the REST API. It has endpoint to update menu item separately but it also has issue regarding menu order and position. These menu and menu items seem like a different beast. 😰

danielbachhuber commented 8 months ago

I also looked at the REST API. It has endpoint to update menu item separately but it also has issue regarding menu order and position.

@ernilambar What is the issue? The same issue?

Feel free to start adding feature tests to this PR, if you'd like.

ernilambar commented 7 months ago

This approach is not solving the exact issue. Need more research on this. Closing this for now.