I am using the Wordboot starters plugin to create my own plugin. This plugin uses the PHP singleton
method to prevent multiple plugin initializations.
Right now, when a visitor sends a contact form, a pure Javascript XHR AJAX
call is executed to handle the contact request.
Everything works fine but I noticed the singleton is not working properly since for each AJAX request the plugin is executing the __construct
of the main Wordboot
class. This means everytime when such request is executed, the whole plugin is initialized again!
I used the Wordpress REST API
and the usual way wp_ajax
for executing AJAX calls but both methods makes this behaviour.
I was wondering if someone could explain me more about this, and how I could prevent a new plugin initialization when an AJAX call is executed?
I'm using the latest version of Wordpress.
__construct
method.