Where must the registration function go? (register_rest_route())
- Must it be in theme/child functions.php?
- Or can it be in the plugin base php file? (e.g. \wp-content\plugins\example\example.php)
Is there any documentation that clarifies this?
It is not mentioned in the official documentation at: https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/
Similarly, where must the endpoint function be stored? The registration function only names it, without specifying its path.
For example, can you do like this:
- Registration function call (
register_rest_route) goes in main plugin file (e.g. \wp-content\plugins\example\example.php) - Endpoint function is in some other plugin file (e.g. \wp-content\plugins\example\sub-path-stuff\example-controller.php)
If so, how?
The following link appears to attempt this but does not specify these attributes (e.g. \wp-content\plugins\example\example.php)