I want to know how wordpress plugins are instantiated, if Wordpress creates a instance of plugins every time that a request is made to wordpress?
Example. I open /wp-admin: The plugin is instantiated I open /: The plugin is instantiated ... etc
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
Instantiate in the strict sense is to create an instance of an object from a class. Plugins aren't necessarily class-based, so I'm not entirely sure what you mean by instantiate.
That said, WordPress includes the main plugin file for all active plugins on every front end and admin request. Whether this "instantiates" your plugin depends on where that instance is created (or what you mean by instantiate).
Plugin interaction with WordPress core happens via actions which you hook functions or methods to. Some actions run on both front end and admin requests, others run on only front end or only admin requests, and some can run multiple times within a single request.
If the plugin is active it is available on every page load (inside or outside) of /wp-admin. Instantiation happens when leveraging a hook or directly calling your code execution of an active plugin. By using hooks you can init code in a more modular or conditional manner. The
*_options table contains a row
active_plugins which stores a serialized array of relative paths to the active plugin files to fire against in
/wp-admin/includes/plugin.php during page init.