Make WordPress Core


Ignore:
Timestamp:
02/20/2024 07:09:43 AM (3 months ago)
Author:
youknowriad
Message:

Editor: Format and sanitize font family names according the CSS spec.

This fixes two bugs in the font library.

  • Fonts using special characters were not being rendered properly in the frontend.
  • Allows the ability to use generic() in font family names.

Props mmaattiiaass, nithins53, kafleg, vivekawsm, swissspidy, audrasjb.
Fixes #60537.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/fonts/class-wp-font-collection.php

    r57539 r57657  
    220220                    'font_family_settings' => array(
    221221                        'name'       => 'sanitize_text_field',
    222                         'slug'       => 'sanitize_title',
    223                         'fontFamily' => 'sanitize_text_field',
     222                        'slug'       => static function ( $value ) {
     223                            return _wp_to_kebab_case( sanitize_title( $value ) );
     224                        },
     225                        'fontFamily' => 'WP_Font_Utils::sanitize_font_family',
    224226                        'preview'    => 'sanitize_url',
    225227                        'fontFace'   => array(
Note: See TracChangeset for help on using the changeset viewer.