WordPress API vs JavaScript to PHP
-
At the moment I have a few plugins which are pretty frontend heavy and allow end users to create WordPress items, mainly users and posts and custom posts with custom fields. At the moment I achieve this using forms/buttons etc. and send the data from JavaScript to PHP using wp_ajax_nopriv and then call standard WordPress functions to achieve certain actions with a lot of sanitization and validation beforehand.
I am considering moving some of this to the WordPress API in the hope it may make the code simpler – so creating API requests in JavaScript and not sending anything to PHP.
I just wanted to get people’s opinions on the pros and cons of these 2 approaches particularly in regards to speed and also security. Like do you need to be as cautious in regards to sanitization and validation when working with the WordPress API or does it just reject any junk sent to it. Do I even need to sanitize and validate data when using the WordPress API?
Thanks,
- The topic ‘WordPress API vs JavaScript to PHP’ is closed to new replies.