Download file using cURL into wp-includes/uploads

There is special wp_upload_bits() function to upload the content to the ‘uploads’ directory. Also, there is no such directory as /wp-includes/upload/. The code was not tested! <?php $video_id = ‘xxxxxxxxxxxxx’; $thumbnail_types = array( ‘0’, ‘1’, ‘2’, ‘3’, ‘default’, ‘sddefault’, ‘mqdefault’, ‘hqdefault’, ‘maxresdefault’, ); foreach( $thumbnail_types as $type ) { $file_name = $type . ‘.jpg’; $youtube_thumb_url=”http://img.youtube.com/vi/” … Read more

WordPress from url get external source title

Here you go: class UrlToTitleConverter{ public function convert($Url){ $response = wp_remote_get($Url); if ( is_array( $response ) ) { $body = $response[‘body’]; $title = substr($body, strpos($body, ‘<title>’)+7); $title = substr($title, 0, strpos($title, ‘</title>’)); } return $title; } }

How to send file by wp_remote_post?

I found an solution for this issue, i using wp_remote_post to send binary of file to server. When processing data received on server, i use this code to get data of file $file = file_get_contents(‘php://input’); And i write it to temp file $temp = tmpfile(); fwrite($temp, $file); $metadata = stream_get_meta_data($temp); Do you have any other … Read more