Skip to content

Commit

Permalink
Replace trigger_error()
Browse files Browse the repository at this point in the history
1. Uses _doing_it_wrong() until wp_trigger_error() is available.
2. Adds comment to each with `@todo` annotation as a reminder to replace these later.
  • Loading branch information
hellofromtonya committed Aug 30, 2023
1 parent 1b2bc1c commit e695f6f
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/wp-includes/fonts/class-wp-font-face.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,49 @@ private function validate_font_face_properties( array $font_face ) {

// Check the font-family.
if ( empty( $font_face['font-family'] ) || ! is_string( $font_face['font-family'] ) ) {
trigger_error( 'Font font-family must be a non-empty string.' );
// @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'] ) ) ) {
trigger_error( 'Font src must be a non-empty string or an array of strings.' );
// @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.
if ( ! empty( $font_face['src'] ) ) {
foreach ( (array) $font_face['src'] as $src ) {
if ( empty( $src ) || ! is_string( $src ) ) {
trigger_error( 'Each font src must be a non-empty string.' );
// @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'] ) ) {
trigger_error( 'Font font-weight must be a properly formatted string or integer.' );
// @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;
}

Expand Down

0 comments on commit e695f6f

Please sign in to comment.