Changeset 12643 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/header.php
- Timestamp:
- 06/09/2023 07:43:23 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/header.php
r11496 r12643 20 20 ); 21 21 22 echo do_blocks( '<!-- wp:wporg/global-header /-->' ); 22 $local_nav_items = array( 23 '' => __( 'All', 'wporg-plugins' ), 24 'community' => __( 'Community', 'wporg-plugins' ), 25 'commercial' => __( 'Commercial', 'wporg-plugins' ), 26 ); 27 28 global $wp_query; 29 $is_beta = 'beta' === $wp_query->get( 'browse' ); 30 $is_favs = 'favorites' === $wp_query->get( 'browse' ); 31 // The filter bar should not be shown on: 32 // - search: wp-query filters not compatible with ES search. 33 // - singular: not relevant on pages or individual plugins. 34 // - beta: likely unnecessary, these are probably all "community". 35 // - favorites: not necessary. 36 $show_filter_bar = ! ( is_search() || is_singular() || $is_beta || $is_favs ); 37 38 echo do_blocks( '<!-- wp:wporg/global-header /-->' ); // phpcs:ignore 23 39 24 40 ?> … … 48 64 <div id="primary-menu" class="menu"> 49 65 <ul> 50 <?php51 foreach ( $menu_items as $path => $text ) :52 $class = false !== strpos( $_SERVER['REQUEST_URI'], $path ) ? 'active' : ''; // phpcs:ignore66 <?php 67 foreach ( $menu_items as $path => $text ) : // phpcs:ignore 68 $class = false !== strpos( $_SERVER['REQUEST_URI'], $path ) ? 'active' : ''; // phpcs:ignore 53 69 ?> 54 70 <li class="page_item"><a class="<?php echo esc_attr( $class ); ?>" href="<?php echo esc_url( home_url( $path ) ); ?>"><?php echo esc_html( $text ); ?></a></li> 55 <?php endforeach; ?>56 <li><?php get_search_form(); ?></li>71 <?php endforeach; ?> 72 <li><?php get_search_form(); ?></li> 57 73 </ul> 58 74 </div> … … 61 77 </div><!-- .site-branding --> 62 78 </header><!-- #masthead --> 79 80 <?php if ( $show_filter_bar ) : ?> 81 <div class="wporg-filter-bar"> 82 <nav class="wporg-filter-bar__navigation" aria-label="<?php esc_html_e( 'Plugin filters', 'wporg-plugins' ); ?>"> 83 <ul> 84 <?php 85 foreach ( $local_nav_items as $slug => $label ) { 86 $class = ''; 87 if ( 88 // URL contains this filter. 89 ( $slug && str_contains( $_SERVER['REQUEST_URI'], "plugin_business_model=$slug" ) ) || // phpcs:ignore 90 // Set the All item active if no business model is selected. 91 ( ! $slug && false === strpos( $_SERVER['REQUEST_URI'], 'plugin_business_model' ) ) // phpcs:ignore 92 ) { 93 $class = 'is-active'; 94 } 95 $url = home_url( '/' ); 96 if ( $slug ) { 97 $url = add_query_arg( array( 'plugin_business_model' => $slug ) ); 98 } else if ( ! is_home() ) { 99 $url = remove_query_arg( 'plugin_business_model' ); 100 } 101 printf( 102 '<li class="page_item"><a class="%1$s" href="%2$s">%3$s</a></li>', 103 esc_attr( $class ), 104 esc_url( $url ), 105 esc_html( $label ) 106 ); 107 } 108 ?> 109 </ul> 110 </nav> 111 </div> 112 <?php endif; ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)