Make WordPress Core

Changeset 59259


Ignore:
Timestamp:
10/20/2024 01:11:24 PM (4 months ago)
Author:
SergeyBiryukov
Message:

Editor: Replace id attribute with class in WP_Font_Face::get_style_element().

wp_print_font_faces() prints an HTML tag that can be used more than once, so the document could end up having multiple tags with the same id attribute.

The id global attribute defines an identifier (ID) which must be unique in the whole document.

Reference: MDN Web Docs: id.

Follow-up to [56500].

Props mmaattiiaass, peterwilsoncc.
Fixes #62246.

Location:
trunk
Files:
3 edited

Legend:

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

    r58075 r59259  
    230230        $attributes = $this->generate_style_element_attributes();
    231231
    232         return "<style id='wp-fonts-local'{$attributes}>\n%s\n</style>\n";
     232        return "<style class='wp-fonts-local'{$attributes}>\n%s\n</style>\n";
    233233    }
    234234
  • trunk/tests/phpunit/tests/fonts/font-face/wpFontFace/generateAndPrint.php

    r56500 r59259  
    3232    public function test_should_generate_and_print_given_fonts( array $fonts, $expected ) {
    3333        $font_face       = new WP_Font_Face();
    34         $style_element   = "<style id='wp-fonts-local' type='text/css'>\n%s\n</style>\n";
     34        $style_element   = "<style class='wp-fonts-local' type='text/css'>\n%s\n</style>\n";
    3535        $expected_output = sprintf( $style_element, $expected );
    3636
  • trunk/tests/phpunit/tests/fonts/font-face/wpPrintFontFaces.php

    r56540 r59259  
    5656
    5757        $expected_output = <<<CSS
    58 <style id='wp-fonts-local' type='text/css'>
     58<style class='wp-fonts-local' type='text/css'>
    5959@font-face{font-family:"Source Serif Pro";font-style:normal;font-weight:200 900;font-display:fallback;src:url('http://example.com/assets/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');font-stretch:;}
    6060</style>
     
    7777
    7878    private function get_expected_styles_output( $styles ) {
    79         $style_element = "<style id='wp-fonts-local' type='text/css'>\n%s\n</style>\n";
     79        $style_element = "<style class='wp-fonts-local' type='text/css'>\n%s\n</style>\n";
    8080        return sprintf( $style_element, $styles );
    8181    }
Note: See TracChangeset for help on using the changeset viewer.