WordPress-Plugin-Boilerplate
WordPress-Plugin-Boilerplate copied to clipboard
Could not get Ajax to be recognized except in root plugin file
I am executing an ajax request in an admin page that is generated by my plugin. I tried putting the server-side PHP code in various places in classes in '/admin' but they never could be "found". I ended up putting the code in the base PHP file (not in a class) and it works. That's really not where it should go, but.......
Any ideas?
Hey @lwoods,
I have been working on a forked version of the boilerplate which includes an example AJAX call. You can find the example files responsible for the AJAX calls at:
-
plugin/public/assets/plugin-public.js
(lines 21-49) -
plugin/public/class-plugin-ajax.php
(lines 23-39) -
plugin/public/class-plugin-public.php
(lines 83-86) -
plugin/includes/class-plugin.php
(line 121 and lines 243-247)
I hope that helps with your issue.