packages/kirki-framework/module-webfonts/src/Helper.php
public static function download_font_file( $url ) {

		// Gives us access to the download_url() and wp_handle_sideload() functions.
		require_once ABSPATH . 'wp-admin/includes/file.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude

		$timeout_seconds = 5;

		// Download file to temp dir.
		$temp_file = download_url( $url, $timeout_seconds );

		if ( is_wp_error( $temp_file ) ) {
			return false;
		}

		// Array based on $_FILE as seen in PHP file uploads.
		$file = [
			'name'     => basename( $url ),
			'type'     => 'font/woff',
			'tmp_name' => $temp_file,
			'error'    => 0,
			'size'     => filesize( $temp_file ),
		];

		$overrides = [
			'test_type' => false,
			'test_form' => false,
			'test_size' => true,
		];

		// Move the temporary file into the uploads directory.
		$results = wp_handle_sideload( $file, $overrides );

		if ( empty( $results['error'] ) ) {
			return $results['url'];
		}
		return false;
	}
public static function download_font_file( $url ) {

		// Gives us access to the download_url() and wp_handle_sideload() functions.
		require_once ABSPATH . 'wp-admin/includes/file.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude

		$timeout_seconds = 5;

		// Download file to temp dir.
		$temp_file = download_url( $url, $timeout_seconds );

		if ( is_wp_error( $temp_file ) ) {
			return false;
		}

		// Array based on $_FILE as seen in PHP file uploads.
		$file = [
			'name'     => basename( $url ),
			'type'     => 'font/woff',
			'tmp_name' => $temp_file,
			'error'    => 0,
			'size'     => filesize( $temp_file ),
		];

		$overrides = [
			'test_type' => false,
			'test_form' => false,
			'test_size' => true,
		];

		// Move the temporary file into the uploads directory.
		$results = wp_handle_sideload( $file, $overrides );

		if ( empty( $results['error'] ) ) {
			return $results['url'];
		}
		return false;
	}
public static function download_font_file ( $ url ) { // Gives us access to the download_url() and wp_handle_sideload() functions. require_once ABSPATH . 'wp-admin/includes/file.php' ; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude $ timeout_seconds = 5 ; // Download file to temp dir. $ temp_file = download_url ( $ url , $ timeout_seconds ) ; if ( is_wp_error ( $ temp_file ) ) { return false ; } // Array based on $_FILE as seen in PHP file uploads. $ file = [ 'name' => basename ( $ url ) , 'type' => 'font/woff' , 'tmp_name' => $ temp_file , 'error' => 0 , 'size' => filesize ( $ temp_file ) , ] ; $ overrides = [ 'test_type' => false , 'test_form' => false , 'test_size' => true , ] ; // Move the temporary file into the uploads directory. $ results = wp_handle_sideload ( $ file , $ overrides ) ; if ( empty ( $ results [ 'error' ] ) ) { return $ results [ 'url' ] ; } return false ; }
Downloads a font-file and saves it locally.

@access public
@since 3.0.28
@param string $url The URL of the file we want to get.
@return bool
Downloads a font - file and saves it locally .