WordPress.org

Support

Support » Plugins and Hacks » Plugin Order of Execution?

Plugin Order of Execution?

  • I am writing my own plugin but it is entirely embedded in its own class to prevent function name collisions.

    As I wrote the code to hook my plugin into WordPress’s activation and deactivation events, I wondered how my plugin would know that it has already been activated.

    I know I can create an option and then check its value once my activation/deactivation methods are called, but there must be a built-in way that WordPress uses.

    Does the register_activation_hook() and register_deactivation_hook() immediately trigger my activation and deactivation methods (functions) once they are called with the appropriate parameters?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Guess I can only point you to the Codex:

    According to Function Reference/register activation hook, the function register_activation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is activated.

    Also see:
    Function_Reference/register_deactivation_hook

    The hooks have an optional second parameter which adds a position number to when the plugin should become active. If you don’t add a number it defaults to “10”. Many people place a very high number in there (like 50 or even 1000) if they really want their plugin to fire last. Obviously putting a smaller number makes it go earlier in the chain. Since many plugin developers never add this optional element into the activation hook it’s a toss up as to what order all of the 10’s get activated.

    @michaelh: Thanks. I saw that but its still vague with what I am actually looking for: When is the activation hook triggered?

    @harknell: That will be handy but not quite what I was looking for.

    I’ll just end up dissecting WordPress’s _hook()* functions and I’ll post back when I have more information. Heck, I’ll even try to include it in the documentation some where.

    Also
    Writing_a_Plugin and the resource section.
    Plugin_API

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Plugin Order of Execution?’ is closed to new replies.