Title: WP_Font_Face::order_src
Published: November 8, 2023
Last modified: August 20, 2026

---

# WP_Font_Face::order_src( array $font_face ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#changelog)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Orders `src` items to optimize for browser support.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#parameters)󠁿

 `$font_face`arrayrequired

Font face to process.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#return)󠁿

 array Font-face with ordered src items.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#source)󠁿

    ```php
    private function order_src( array $font_face ) {
    	if ( ! is_array( $font_face['src'] ) ) {
    		$font_face['src'] = (array) $font_face['src'];
    	}

    	$src         = array();
    	$src_ordered = array();

    	foreach ( $font_face['src'] as $url ) {
    		// Add data URIs first.
    		if ( str_starts_with( trim( $url ), 'data:' ) ) {
    			$src_ordered[] = array(
    				'url'    => $url,
    				'format' => 'data',
    			);
    			continue;
    		}
    		$format         = pathinfo( $url, PATHINFO_EXTENSION );
    		$src[ $format ] = $url;
    	}

    	// Add woff2.
    	if ( ! empty( $src['woff2'] ) ) {
    		$src_ordered[] = array(
    			'url'    => $src['woff2'],
    			'format' => 'woff2',
    		);
    	}

    	// Add woff.
    	if ( ! empty( $src['woff'] ) ) {
    		$src_ordered[] = array(
    			'url'    => $src['woff'],
    			'format' => 'woff',
    		);
    	}

    	// Add ttf.
    	if ( ! empty( $src['ttf'] ) ) {
    		$src_ordered[] = array(
    			'url'    => $src['ttf'],
    			'format' => 'truetype',
    		);
    	}

    	// Add eot.
    	if ( ! empty( $src['eot'] ) ) {
    		$src_ordered[] = array(
    			'url'    => $src['eot'],
    			'format' => 'embedded-opentype',
    		);
    	}

    	// Add otf.
    	if ( ! empty( $src['otf'] ) ) {
    		$src_ordered[] = array(
    			'url'    => $src['otf'],
    			'format' => 'opentype',
    		);
    	}
    	$font_face['src'] = $src_ordered;

    	return $font_face;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/fonts/class-wp-font-face.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/fonts/class-wp-font-face.php#L234)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/fonts/class-wp-font-face.php#L234-L297)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Font_Face::get_css()](https://developer.wordpress.org/reference/classes/wp_font_face/get_css/)`wp-includes/fonts/class-wp-font-face.php` |

Gets the `@font-face` CSS styles for locally-hosted font files.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_font_face/order_src/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_font_face%2Forder_src%2F)
before being able to contribute a note or feedback.