WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to delay a remove_action call until all other plugins are loaded (5 posts)

  1. derekbeck
    Member
    Posted 1 year ago #

    I'm using the Simple Facebook Connect plugin, but I implement my own metadeta and don't want the metadata from SFC.

    Short of hacking the SFC plugin itself, as I don't want to do it everytime there's an update, how can I call this code in my own custom plugin, but force it to run after all other plugins:

    remove_action('wp_head','sfc_base_meta');

    What is the code to reserve the above until all other plugins are loaded?

    Presently, my personal site plugin for tweaks and functionality is running before SFC, and so the remove_action call is trumped later by SFC's add_action call.

    Thanks!
    Derek

  2. bcworkz
    Member
    Posted 1 year ago #

    Execute your code inside a hook to any action that fires late enough. 'plugins_loaded' or 'wp_loaded' are a couple possibilities. For extra insurance, add your hook using a low priority (bigger) number so it hopefully runs later than any conflicting hook added by another plugin.

  3. derekbeck
    Member
    Posted 1 year ago #

    Unfortunately, this does not work. I hooked it to wp_footer but still, my functionality plugin loads first, so it seems irrelevant. Any other ideas?

  4. derekbeck
    Member
    Posted 1 year ago #

    Okay, not ideal, but seems the simplest if not only solution is to name my plugin higher up in the alphabet than the offending plugin. Then hook exactly as that plugin is hooking. In other words, name my custom plugin to begin with a "z", and that fixed it.

  5. derekbeck
    Member
    Posted 1 year ago #

    Okay, here's the solution:

    function PluginsOverride() {
    	remove_action('wp_head','sfc_base_meta');
    	remove_action('wp_footer','sfc_add_base_js',20);
    }
    add_action('plugins_loaded','PluginsOverride');

    The key is: add whatever "remove_action"s or whatever to inside a function like above, then hook that new function to the point when plugins_loaded is done.

    Thanks to Otto, who tweeted me this solution!

Topic Closed

This topic has been closed to new replies.

About this Topic