Correct place to load an extension in WordPress

My hosting provider does not have curl extension enabled by default, however, I can load it using dl().

What would be the correct place in WordPress to load the extension so that it could use curl for wp_remote_* functions?

Read More

I’d like it to survive the possible upgrades of WordPress code.

Related posts

Leave a Reply

1 comment

  1. The earliest hook I know of is init. My recommendation would be to build this as a plug-in (so that it will survive upgrades) and do the following:

    add_action('init', 'load_curl_functions');
    
    function load_curl_functions() {
        //Use dl() to load curl
    }
    

    —- EDIT —-

    It looks like there are some hooks that fire before init. I recommend trying to hook to load_textdomain instead. This is the hook that loads language and translation functions (the only hook that fires earlier is muplugins_loaded which might not work in non-mu installations).

    So: add_action('load_textdomain', 'load_curl_functions'); should load your curl extension before doing anything else …