Astra_WebFont_Loader::get_remote_url_contents()
Get remote file contents.
Description
Return
(string) Returns the remote URL contents.
Source
File: inc/lib/webfont/class-astra-webfont-loader.php
public function get_remote_url_contents() { /** * The user-agent we want to use. * * The default user-agent is the only one compatible with woff (not woff2) * which also supports unicode ranges. */ $user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8'; // Switch to a user-agent supporting woff2 if we don't need to support IE. if ( 'woff2' === $this->font_format ) { $user_agent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0'; } // Get the response. $response = wp_remote_get( $this->remote_url, array( 'user-agent' => $user_agent ) ); // Early exit if there was an error. if ( is_wp_error( $response ) ) { return ''; } // Get the CSS from our response. $contents = wp_remote_retrieve_body( $response ); return $contents; }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |