/** * Retrieve the content of a local or remote file. * * @param $url The resource URL. * @return string */ function thb_read_url($url) { if (thb_text_startsWith($url, WP_CONTENT_URL)) { return file_get_contents(thb_system_get_path($url)); } else { $response = wp_remote_get($url); if (thb_response_is_ok($response)) { return $response['body']; } } return ''; }
/** * Grab the changelog data. * * @return stdClass */ private function _grabChangelog() { $data = wp_remote_get(THB_UPDATE_CHANGELOG_DISPATCHER); if (!thb_response_is_ok($data)) { return false; } else { return $data['body']; } }
function thb_get_video_thumbnail($url, $key = '') { $thumbnail = ''; $is_youtube = strpos($url, 'youtu') !== false; $is_vimeo = strpos($url, 'vimeo') !== false; if ($is_youtube || $is_vimeo) { $code = thb_get_video_code($url); if ($is_vimeo) { $req = wp_remote_get("http://vimeo.com/api/v2/video/{$code}.php"); if (thb_response_is_ok($req)) { $data = unserialize($req['body']); $thumbnail = $data[0][$key]; } } elseif ($is_youtube) { $thumbnail = "http://img.youtube.com/vi/{$code}/hqdefault.jpg"; } } else { return ''; } return $thumbnail; }