wordpress

时间:2017-07-28 18:26:51

标签: php wordpress

我有这个代码使用curl替换删除图像它没有问题,但我想使用wordpress本机函数来完成此任务。

function image( $destination_path, $remote_image_link ) {
    $ch =  curl_init( $remote_image_link );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    $result = curl_exec( $ch );

    if ( $result ) {
        $rv = file_put_contents( $destination_path, $result );
    }
}

希望与wp_remote或其他功能相同。任何帮助都会很棒

1 个答案:

答案 0 :(得分:0)

答案非常简单。

wp_remote_get输出是大数组,并且该数组主体包含主要细节,因为这里只有一个链接只需要做

$result = wp_remote_get($remote_image_link['body']); 

希望它可以帮助某人,因为wp文档不明确