WordPress.org

Ready to get started?Download WordPress

Forums

Plugin Execution order (4 posts)

  1. gr
    Member
    Posted 9 years ago #

    Maybe I'm off here, but I would like to know how the plugins get executed, and in what order.

    Basically, I am running wp-stattraq along with spam karma 2. I would like to get spam karma 2 to kill spam posts before they get logged by stattraq. One way I thought of doing this was to get execution to end at spam karma before stattraq logs it. Or to have stattraq check some spam karma exit value, or other variable set by spam karma before it logs.

    Any hints?

  2. davidchait
    Member
    Posted 9 years ago #

    I think it's the order the plugins were activated.

    HOWEVER, that's just the order they are INITIALIZED. How and when they actually execute is dependent on the plugin.

    Usually the anti-spam stuff doesn't kick in until the actuall processing of the comment (that's when CG-AntiSpam does its work at least). However, something like CG-Referrer purposefully tracks and punts when plugins finish loading, in order to abort as early as possible. In theory, Referrer (and other stats plugins) could do checks in the initialization/plugins-loaded point, but then not log the visit until maybe wp_foot or other late point. However, just because a spam post got killed doesn't necessarily mean wp_foot (or other 'late' action points) doesn't get hit as well.

    Probably means some custom code may be required. ;)

    -d

  3. richschmidt
    Member
    Posted 8 years ago #

    I'm interested in learning in what order plugins are executed also. I'm running two that interfere with each other:

    1. autohyperlink - automagically transforms http://www.whatever.com into a link and me@whatever.com into a mailto link. (Just like this forum does, evidently.)

    2. email immunizer - turns email addresses into numeric codes to try to protect from harvesters.

    The problem is that the immunizer gets to the email addresses first, which means autohyperlink doesn't recognize it as an email address & doesn't work its magic. If I could make them execute in the opposite order, it'd be perfect.

    Any ideas?

    It looks like autohyperlink gets its work done with add_filter('the_content','autohyperlink_filter'); and add_action('publish_post','autohyperlink_filter');. Email immunizer does a set of 9 add_filter(); commands, one of which is add_filter('the_content', 'email_immunizer', 9);. Evidently that's where the conflict happens...

  4. richschmidt
    Member
    Posted 8 years ago #

    OK, I figured that one out. :) The "9" in the email immunizer add_filter() tipped me off. It's a priority argument. I changed the 9's to 30's, and now the autohyperlink gets done first. (There's info on this in the Codex: http://codex.wordpress.org/Plugin_API#Filters . It just took me a while to find it.)

    I went with 30 because I have no idea how many add_filter() commands there are on my system at the moment. I didn't want to adjust the autohyperlink priority & jam up something else...

    What can I say? I'm new at this! :)

Topic Closed

This topic has been closed to new replies.

About this Topic