Making WordPress.org


Ignore:
Timestamp:
12/11/2023 09:44:25 PM (18 months ago)
Author:
coffee2code
Message:

Theme Directory: Improve appearance of menubar link.

Improves hover design and adds current page recognition and design. Not perfect, but good enough for the one link it needs to handle.

Props sabernhardt, coffee2code.
See #6552.

File:
1 edited

Legend:

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

    r12655 r13048  
    1010echo do_blocks( '<!-- wp:wporg/global-header /-->' );
    1111
     12$menu_links = [
     13    home_url( '/commercial/' ) => __( 'Commercial Themes', 'wporg-themes' ),
     14];
    1215?>
    1316<header id="masthead" class="site-header <?php echo is_home() ? 'home' : ''; ?>" role="banner">
     
    3841<nav id="site-navigation" class="main-navigation" role="navigation">
    3942    <ul id="menu-theme-directory" class="menu">
    40         <li><a href="<?php echo home_url( '/commercial/' ); ?>"><?php _e( 'Commercial Themes', 'wporg-themes' ); ?></a></li>
     43        <?php
     44        foreach ( $menu_links as $url => $text ) :
     45            $is_current_page = 0 === strpos( "https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}", $url );
     46            $class = $is_current_page ? ' class="current-menu-item"' : '';
     47        ?>
     48        <li<?php echo $class; ?>><a href="<?php echo esc_url( $url ); ?>"><?php echo $text; ?></a></li>
     49        <?php endforeach; ?>
    4150    </ul>
    4251</nav>
Note: See TracChangeset for help on using the changeset viewer.