10up / simple-page-ordering

Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
https://wordpress.org/plugins/simple-page-ordering/
GNU General Public License v2.0
144 stars 22 forks source link

Feature/rest api reordering post #74

Closed ciprianimike closed 2 years ago

ciprianimike commented 2 years ago

Description of the Change

The function ajax_simple_page_ordering() is the callback function of the AJAX call, it was also responsible for saving the position of the posts.

A refactor has been done, moving the sorting and posts updating part into a new page_ordering() function.

The REST endpoint has been added: wp-json/simplepageordering/v1/page_ordering/

The rest_page_ordering() function has been added as callback for the new REST endpoint and it calls the page_ordering() function.

page_ordering() is therefore the part of the code where the sorting of post takes place and this is now called via AJAX or REST.

Verification Process

after taking some of the code out of the ajax_simple_page_ordering () function, I made sure that the operation remained intact, verifying the parameters sent in the request before the refactor and replicating them after the refactor.

I then sent the same parameters through the new REST endpoint and verified that the reordering is consistent, the same parameters via AJAX or REST must lead to the usual sorting results.

Checklist:

Applicable Issues

https://github.com/10up/simple-page-ordering/issues/67

ciprianimike commented 2 years ago

@cadic got it, added parameters required and default