Making WordPress.org

Changeset 13631


Ignore:
Timestamp:
04/30/2024 10:58:08 PM (7 weeks ago)
Author:
coffee2code
Message:

Breathe: Use SVG icon for Openverse and Performance team sites.

Fixes #6374.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/functions.php

    r13175 r13631  
    326326
    327327/**
     328 * Outputs team icons represented via SVG images using the `svg` tag (as opposed to via CSS).
     329 *
     330 * While the SVG could easily, and more cleanly, be added via CSS, doing so would not allow the SVGs
     331 * to otherwise inherit the link colors (such as on :hover). If the theme changes to move the team
     332 * icon outside of the link, or if matching the link color is no longer required, then the SVG
     333 * definitions can be moved to CSS.
     334 *
     335 * Currently handles the following teams:
     336 * - Core Performance
     337 * - Openverse
     338 *
     339 * Note: Defining a team's icon in this way also requires adjusting the site's styles to not expect
     340 * a ::before content of a dashicon font character. (Search style.css for: Adjustments for teams with SVG icons.)
     341 */
     342function add_svg_icon_to_site_name() {
     343    $site = get_site();
     344
     345    if ( ! $site ) {
     346        return;
     347    }
     348
     349    $svg = [];
     350
     351    if ( '/openverse/' === $site->path ) :
     352        $svg = [
     353            'viewbox' => '0 16 200 200',
     354            'paths'   => [
     355                'M142.044 93.023c16.159 0 29.259-13.213 29.259-29.512 0-16.298-13.1-29.511-29.259-29.511s-29.259 13.213-29.259 29.511c0 16.299 13.1 29.512 29.259 29.512ZM28 63.511c0 16.24 12.994 29.512 29.074 29.512V34C40.994 34 28 47.19 28 63.511ZM70.392 63.511c0 16.24 12.994 29.512 29.074 29.512V34c-15.998 0-29.074 13.19-29.074 29.511ZM142.044 165.975c16.159 0 29.259-13.213 29.259-29.512 0-16.298-13.1-29.511-29.259-29.511s-29.259 13.213-29.259 29.511c0 16.299 13.1 29.512 29.259 29.512ZM70.392 136.414c0 16.257 12.994 29.544 29.074 29.544v-59.006c-15.999 0-29.074 13.204-29.074 29.462ZM28 136.414c0 16.34 12.994 29.544 29.074 29.544v-59.006c-16.08 0-29.074 13.204-29.074 29.462Z',
     356            ],
     357        ];
     358
     359    elseif ( '/performance/' === $site->path ) :
     360        $svg = [
     361            'viewbox' => '0 8 94 94',
     362            'paths'   => [
     363                'M39.21 20.85h-11.69c-1.38 0-2.5 1.12-2.5 2.5v11.69c0 1.38 1.12 2.5 2.5 2.5h11.69c1.38 0 2.5-1.12 2.5-2.5v-11.69c0-1.38-1.12-2.5-2.5-2.5z',
     364                'M41.71,58.96v11.69c0,.66-.26,1.3-.73,1.77-.47,.47-1.11,.73-1.77,.73h-11.69c-.66,0-1.3-.26-1.77-.73-.47-.47-.73-1.11-.73-1.77v-21.37c0-.4,.1-.79,.28-1.14,.03-.06,.07-.12,.1-.18,.21-.33,.49-.61,.83-.82l11.67-7.04c.44-.27,.95-.39,1.47-.36,.51,.03,1,.23,1.4,.55,.26,.21,.47,.46,.63,.75,.16,.29,.26,.61,.29,.94,.02,.11,.02,.22,.02,.34v5.38s0,.07,0,.11v11.08s0,.04,0,.07Z',
     365                'M68.98,30.23v16.84c0,.33-.06,.65-.19,.96-.13,.3-.31,.58-.54,.81l-6.88,6.88c-.23,.23-.51,.42-.81,.54-.3,.13-.63,.19-.96,.19h-13.15c-.66,0-1.3-.26-1.77-.73-.47-.47-.73-1.11-.73-1.77v-11.69c0-.66,.26-1.3,.73-1.77,.47-.47,1.11-.73,1.77-.73h13.08s1.11,0,1.11-1.11-1.11-1.11-1.11-1.11h-13.08c-.66,0-1.3-.26-1.77-.73s-.73-1.11-.73-1.77v-11.69c0-.66,.26-1.3,.73-1.77,.47-.47,1.11-.73,1.77-.73h13.15c.33,0,.65,.06,.96,.19,.3,.13,.58,.31,.81,.54l6.88,6.88c.23,.23,.42,.51,.54,.81,.13,.3,.19,.63,.19,.96Z',
     366            ],
     367        ];
     368
     369    endif;
     370
     371    if ( empty( $svg['viewbox'] ) || empty( $svg['paths'] ) ) {
     372        return;
     373    }
     374
     375    printf( '<svg aria-hidden="true" role="img" viewBox="%s" xmlns="http://www.w3.org/2000/svg">' . "\n", esc_attr( $svg['viewbox'] ) );
     376
     377    foreach ( $svg['paths'] as $path ) {
     378        printf( "\t" . '<path d="%s" stroke="currentColor" fill="currentColor"/>' . "\n", esc_attr( $path ) );
     379    }
     380
     381    echo "</svg>\n";
     382}
     383add_action( 'wporg_breathe_before_name', __NAMESPACE__ . '\add_svg_icon_to_site_name' );
     384
     385/**
    328386 * Register translations for plugins without their own GlotPress project.
    329387 */
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/header.php

    r11496 r13631  
    1010    <div class="site-branding">
    1111        <?php if ( is_front_page() && is_home() ) : ?>
    12             <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     12            <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php do_action( 'wporg_breathe_before_name', 'front' ); ?><?php bloginfo( 'name' ); ?></a></h1>
    1313        <?php else : ?>
    14             <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     14            <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php do_action( 'wporg_breathe_before_name', 'nonfront' ); ?><?php bloginfo( 'name' ); ?></a></p>
    1515        <?php endif; ?>
    1616    </div>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/style.css

    r13494 r13631  
    305305body.wporg-make #headline h2 a:before {
    306306    vertical-align: middle; /* overrides wp4.css */
     307}
     308
     309/* Adjustments for teams with SVG icons. */
     310.wporg-make.make-openverse .site-title a::before,
     311.wporg-make.make-performance .site-title a::before {
     312    content: '';
     313    width: 0;
     314}
     315.site-title svg {
     316    height: 30px;
     317    width: 30px;
     318    vertical-align: middle;
    307319}
    308320
Note: See TracChangeset for help on using the changeset viewer.