Title: WP_Font_Face::validate_font_face_declarations
Published: November 8, 2023
Last modified: February 24, 2026

---

# WP_Font_Face::validate_font_face_declarations( array $font_face ): array|false

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/classes/wp_font_face/validate_font_face_declarations/?output_format=md#wp--skip-link--target)

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.

Validates each font-face declaration (property and value pairing).

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

 `$font_face`arrayrequired

Font face property and value pairings to validate.

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

 array|false Validated font-face on success, or false on failure.

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

    ```php
    private function validate_font_face_declarations( array $font_face ) {
    	$font_face = wp_parse_args( $font_face, $this->font_face_property_defaults );

    	// Check the font-family.
    	if ( empty( $font_face['font-family'] ) || ! is_string( $font_face['font-family'] ) ) {
    		// @todo replace with `wp_trigger_error()`.
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Font font-family must be a non-empty string.' ),
    			'6.4.0'
    		);
    		return false;
    	}

    	// Make sure that local fonts have 'src' defined.
    	if ( empty( $font_face['src'] ) || ( ! is_string( $font_face['src'] ) && ! is_array( $font_face['src'] ) ) ) {
    		// @todo replace with `wp_trigger_error()`.
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Font src must be a non-empty string or an array of strings.' ),
    			'6.4.0'
    		);
    		return false;
    	}

    	// Validate the 'src' property.
    	foreach ( (array) $font_face['src'] as $src ) {
    		if ( empty( $src ) || ! is_string( $src ) ) {
    			// @todo replace with `wp_trigger_error()`.
    			_doing_it_wrong(
    				__METHOD__,
    				__( 'Each font src must be a non-empty string.' ),
    				'6.4.0'
    			);
    			return false;
    		}
    	}

    	// Check the font-weight.
    	if ( ! is_string( $font_face['font-weight'] ) && ! is_int( $font_face['font-weight'] ) ) {
    		// @todo replace with `wp_trigger_error()`.
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Font font-weight must be a properly formatted string or integer.' ),
    			'6.4.0'
    		);
    		return false;
    	}

    	// Check the font-display.
    	if ( ! in_array( $font_face['font-display'], $this->valid_font_display, true ) ) {
    		$font_face['font-display'] = $this->font_face_property_defaults['font-display'];
    	}

    	// Remove invalid properties.
    	foreach ( $font_face as $property => $value ) {
    		if ( ! in_array( $property, $this->valid_font_face_properties, true ) ) {
    			unset( $font_face[ $property ] );
    		}
    	}

    	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/6.9.4/src/wp-includes/fonts/class-wp-font-face.php#L158)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/fonts/class-wp-font-face.php#L158-L220)

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

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_font_face/validate_font_face_declarations/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_font_face/validate_font_face_declarations/?output_format=md#)

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

Validates each of the font-face properties.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_font_face/validate_font_face_declarations/?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%2Fvalidate_font_face_declarations%2F)
before being able to contribute a note or feedback.