WordPress.org

Ready to get started?Download WordPress

Forums

Plugin Order of Execution? (5 posts)

  1. kherge
    Member
    Posted 6 years ago #

    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?

  2. MichaelH
    Member
    Posted 6 years ago #

    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

  3. harknell
    Member
    Posted 6 years ago #

    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.

  4. kherge
    Member
    Posted 6 years ago #

    @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.

  5. MichaelH
    Member
    Posted 6 years ago #

    Also
    Writing_a_Plugin and the resource section.
    Plugin_API

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags