开发者

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 d开发者_高级运维l().

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜