我有一个调用wp_remote_post的插件。我想有一个选项来指定传输,因为对于某些用户,curl在特定情况下会抛出错误。
最好的方法是什么?
我尝试使用requests-requests.before_request操作,但我不知道如何通过引用传递选项。 Wordpress在do_action_ref_array的文档中声明参数不会通过引用传递。
我有这段代码:
在调用wp_remote_post之前:
add_action( 'requests-requests.before_request', array( __CLASS__, 'before_request' ), 10, 5 );
然后功能:
public static function before_request( $url, $headers, $data, $type, &$options ) {
$options['transport'] = 'Requests_Transport_fsockopen';
}
但是,没有成功。