tags:

views:

37

answers:

1

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?

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

+2  A: 

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

EAMann
or if you are doing this for something in the theme. Add that to your functions page.
percent20
Actually, I only need curl extension when loading the dashboard (it is required by Google Analytics plugin's admin mode). Wouldn't loading `curl.so` on each page view be much of an overhead?
Quassnoi
In that case, use the `plugins_loaded` hook. It's the first hook to fire for an admin page request.
EAMann
Seems to work nice, thanks.
Quassnoi