is_option_enabled( 'limit_google_fonts_support_for_legacy_browsers' ); $uas = []; if ( ! $limit_support ) { /** * IE9 Compat Modes */ $uas['eot'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)'; /** * Legacy iOS */ $uas['svg'] = 'Mozilla/4.0 (iPad; CPU OS 4_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/4.1 Mobile/9A405 Safari/7534.48.3'; } /** * Safari, Android, iOS */ $uas['ttf'] = 'Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) Safari/538.1 Daum/4.1'; /** * Modern Browsers. * Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ $uas['woff'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0'; /** * Super Modern Browsers. * hrome 26+, Opera 23+, Firefox 39+ */ $uas['woff2'] = 'Mozilla/5.0 (Windows NT 6.3; rv:39.0) Gecko/20100101 Firefox/39.0'; /** * Filters which user agents to use to get google fonts. * * @since 4.10.0 */ return apply_filters( 'et_builder_google_fonts_user_agents', $uas ); } /** * Fetch CSS file contents from google fonts URL. * * @since 4.10.0 * * @param string $url The Google Fonts URL to fetch the contents for. * * @return string $url CSS file contents. */ public function fetch( $url ) { $all_contents = '/* Original: ' . esc_url( $url ) . ' */'; foreach ( $this->_get_user_agents() as $ua ) { $response = wp_remote_get( esc_url_raw( $url ), [ 'user-agent' => $ua, ] ); // Return if there is no response or if there is an error. if ( ! is_array( $response ) || is_wp_error( $response ) ) { return false; } $contents = wp_remote_retrieve_body( $response ); $contents = '/* User Agent: ' . $ua . ' */' . "\n" . $contents; $all_contents .= "\n\n" . $contents; } /** * Filter the unminified CSS file contents after loading it from Googles servers. * * @since 4.19.1 * * @param string $all_contents The concatenated CSS files content that was fetched from Google. * @param string $url The Google Fonts URL that was fetched. */ $all_contents = apply_filters( 'et_builder_google_fonts_fetch_content', $all_contents, $url ); $all_contents = self::minify( $all_contents ); return $all_contents; } /** * Minify CSS string. * * @since 4.10.0 * * @param string $data Multiline CSS data. * * @return string Minifed CSS data. */ public static function minify( $data ) { $data = trim( $data ); $data = preg_replace( '/\n/smi', '', $data ); $data = preg_replace( '/\s\s/smi', '', $data ); return $data; } }