Making WordPress.org

Changeset 9230


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

Plugin Directory: Fix some HTML validation errors.

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

See #4730.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 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
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin-icon/index.jsx

    r5024 r9230  
    3434    return (
    3535        <div className="entry-thumbnail">
    36             <div className="plugin-icon" id={ `plugin-icon-${ slug }` } />
     36            <div className="{ `plugin-icon plugin-icon-${ slug }` }" />
    3737            <style type="text/css">
    38                 { `#plugin-icon-${ slug } { background-image: url('${ icon }'); }` }
     38                { `.plugin-icon-${ slug } { background-image: url('${ icon }'); }` }
    3939                { icons[ '2x' ] && icon !== icons.default
    4040                    // eslint-disable-next-line max-len
    41                     ? `@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #plugin-icon-${ slug } { background-image: url('${ icons[ '2x' ] }'); } }`
     41                    ? `@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { .plugin-icon-${ slug } { background-image: url('${ icons[ '2x' ] }'); } }`
    4242                    : ''
    4343                }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin.php

    r6284 r9230  
    1414$tested_up_to = (string) get_post_meta( $post->ID, 'tested', true );
    1515?>
    16 <article id="post-<?php the_ID(); ?>" <?php post_class( 'plugin-card' ); ?>>
     16<article <?php post_class( 'plugin-card' ); ?>>
    1717    <div class="entry-thumbnail">
     18        <?php
     19            $icon_parts = Template::get_plugin_icon( get_post(), 'html-parts' );
     20            echo $icon_parts['style_tag'];
     21        ?>
    1822        <a href="<?php the_permalink(); ?>" rel="bookmark">
    19             <?php
    20             // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
    21             echo Template::get_plugin_icon( get_post(), 'html' );
    22             ?>
     23            <?php echo $icon_parts['icon_tag']; ?>
    2324        </a>
    2425    </div><div class="entry">
     
    6061        </span>
    6162    </footer>
     63    <?php /* This file must not end with a new line */ ?>
    6264</article>
Note: See TracChangeset for help on using the changeset viewer.