Making WordPress.org


Ignore:
Timestamp:
10/24/2019 06:54:36 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Fix some HTML validation errors.

  • Remove duplicate ID's
  • Don't nest <style> under <a>

See #4730.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r9190 r9230  
    503503
    504504                switch ( $output ) {
     505                        case 'html-parts':
    505506                        case 'html':
    506                                 $id    = "plugin-icon-{$plugin->post_name}";
    507                                 $html  = "<style type='text/css'>";
    508                                 $html .= "#{$id} { background-image: url('{$icon}'); }";
     507                                $id         = esc_attr( "plugin-icon-{$plugin->post_name}" );
     508                                $style_tag  = "<style type='text/css'>";
     509                                $style_tag .= ".{$id} { background-image: url('{$icon}'); }";
    509510                                if ( ! empty( $icon_2x ) && ! $generated && ! $svg ) {
    510                                         $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }";
    511                                 }
    512                                 $html .= '</style>';
    513                                 $html .= "<div class='plugin-icon' id='{$id}'></div>";
    514 
    515                                 return $html;
     511                                        $style_tag .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { .{$id} { background-image: url('{$icon_2x}'); } }";
     512                                }
     513                                $style_tag .= '</style>';
     514
     515                                $icon_tag   = "<div class='plugin-icon {$id}'></div>";
     516
     517                                if ( 'html' === $output ) {
     518                                        return $style_tag . $icon_tag;
     519                                } else {
     520                                        return compact( 'style_tag', 'icon_tag' );
     521                                }
    516522                                break;
    517523
Note: See TracChangeset for help on using the changeset viewer.