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

  • Short answer, yes. You could always test it out by putting a die() at the top of a plugin file and trying different urls. Commented Mar 21, 2014 at 23:41

2 Answers 2


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.

  • I have a plugin that creates an instance of a class in its main file, so I suppose that on every request, the plugin creates a new object. I am right? Commented Mar 22, 2014 at 0:37
  • 1
    yes, that is correct.
    – Milo
    Commented Mar 22, 2014 at 0:42
  • I have some related question: How should I preserve the same object in every request? Commented Mar 22, 2014 at 0:47
  • It depends on why you need it to persist- per user via sessions, or global via some sort of persistent cache or database. I suggest creating a new question and explaining what you're trying to do or what your needs are.
    – Milo
    Commented Mar 22, 2014 at 3:35

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.