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.
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 thepage_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