Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/wp-includes/fonts/class-wp-font-face.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,46 +137,38 @@ private function validate_font_face_declarations( array $font_face ) {

// 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(
wp_trigger_error(
__METHOD__,
__( 'Font font-family must be a non-empty string.' ),
'6.4.0'
__( 'Font font-family must be a non-empty string.' )
);
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(
wp_trigger_error(
__METHOD__,
__( 'Font src must be a non-empty string or an array of strings.' ),
'6.4.0'
__( 'Font src must be a non-empty string or an array of strings.' )
);
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(
wp_trigger_error(
__METHOD__,
__( 'Each font src must be a non-empty string.' ),
'6.4.0'
__( 'Each font src must be a non-empty string.' )
);
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(
wp_trigger_error(
__METHOD__,
__( 'Font font-weight must be a properly formatted string or integer.' ),
'6.4.0'
__( 'Font font-weight must be a properly formatted string or integer.' )
);
return false;
}
Expand Down
Loading