Changeset 13451
- Timestamp:
- 04/04/2024 02:56:19 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/block-config.php
r13437 r13451 19 19 */ 20 20 function add_site_navigation_menus( $menus ) { 21 21 global $wp; 22 23 $url = 'https://' . $_SERVER['HTTP_HOST'] . parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); 24 22 25 $items = array( 23 26 'plugins' => array( … … 38 41 array( 39 42 'label' => __( 'Community', 'wporg-plugins' ), 40 'url' => is_search() ? esc_url( get_search_link() . '?plugin_business_model=community' ) : home_url('?plugin_business_model=community' ),43 'url' => is_search() ? esc_url( get_search_link() . '?plugin_business_model=community' ) : '?plugin_business_model=community' ), 41 44 'term' => get_term_by( 'slug', 'community', 'plugin_business_model' ), 42 45 ), 43 46 array( 44 47 'label' => __( 'Commercial', 'wporg-plugins' ), 45 'url' => is_search() ? esc_url( get_search_link() . '?plugin_business_model=commercial' ) : home_url('?plugin_business_model=commercial' ),48 'url' => '?plugin_business_model=commercial' ), 46 49 'term' => get_term_by( 'slug', 'commercial', 'plugin_business_model' ), 47 50 ), … … 247 250 } 248 251 249 // If we have a business model selected, the navigation block will select appropriately. 250 if ( ! isset( $wp_query ) || isset( $wp_query->query['plugin_business_model'] ) ) { 252 if ( get_query_var( 'plugin_business_model' ) ) { 253 254 // The menu doesn't select properly if viewing /tags/ or /browse/. 255 if ( get_query_var( 'browse' ) || get_query_var( 'plugin_tags' ) ) { 256 $tags = new \WP_HTML_Tag_Processor( $block_content ); 257 258 while ( $tags->next_tag( 'li' ) ) { 259 $tags->set_bookmark( 'parent-li' ); 260 $tags->next_tag( 'a' ); 261 262 if ( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] === $tags->get_attribute( 'href' ) ) { 263 $tags->seek( 'parent-li' ); 264 $tags->add_class( 'current-menu-item' ); 265 break; 266 } 267 } 268 269 return $tags->get_updated_html(); 270 } 271 251 272 return $block_content; 252 273 } … … 254 275 $tag_processor = new \WP_HTML_Tag_Processor( $block_content ); 255 276 256 if ( $tag_processor->next_tag( 'ul' )) { 277 // Find the first li item and select it. 278 if ( $tag_processor->next_tag( 'ul' ) ) { 257 279 if ( $tag_processor->next_tag( 'li' ) ) { 258 280 $tag_processor->add_class( 'current-menu-item' ); 259 } 260 261 return $tag_processor->get_updated_html();281 282 return $tag_processor->get_updated_html(); 283 262 284 } 263 285
Note: See TracChangeset
for help on using the changeset viewer.