I am in the middle of creating a plugin and everything works fine with the AJAX calls but one question I can't seem to find the answer to is about best practise.
I route the AJAX calls through
/wp-admin/admin-ajax.php and have my php functions in the theme
However, I've just thought that this doesn't seem such a good idea because what do you do when the user activates your plugin, do you need to create a function to write your code to functions.php on activation?
Similarly, what if the user changes theme?
Therefore, I was just wondering if there are other ways to do it or what is the common approach for this type of thing.