diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php index 03f28ed012..ecbd660ee9 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php @@ -407,6 +407,11 @@ function wporg_support_breadcrumb() { $args['include_home'] = true; $args['home_text'] = __( 'Forums', 'wporg-forums' ); + // HelpHub pages aren't part of the forums. + if ( is_singular( array( 'helphub_article', 'helphub_version' ) ) || is_category() ) { + $args['home_text'] = esc_html__( 'Support', 'wporg-forums' ); + } + // Forum root $args['include_root'] = false; @@ -415,6 +420,11 @@ function wporg_support_breadcrumb() { $args['current_before'] = ''; $args['current_after'] = ''; + // bbPress would use the title of the first post in the archive. + if ( is_category() ) { + $args['current_text'] = esc_html( single_cat_title( '', false ) ); + } + return $args; } add_filter( 'bbp_before_get_breadcrumb_parse_args', 'wporg_support_breadcrumb' ); @@ -422,9 +432,27 @@ function wporg_support_breadcrumb() { add_filter( 'bbp_breadcrumbs', /** - * Filters the breadcrumbs to replace the home URL with the forums page. + * Filters the breadcrumbs to replace the home URL with the forums page, + * and to add the category to HelpHub articles. */ function( $crumbs ) { + if ( is_singular( 'helphub_article' ) ) { + $categories = get_the_category( get_queried_object_id() ); + + if ( $categories ) { + $category_crumb = sprintf( + '%2$s', + esc_url( get_category_link( $categories[0] ) ), + esc_html( $categories[0]->name ) + ); + array_splice( $crumbs, 1, 0, $category_crumb ); + } + } + + if ( is_singular( array( 'helphub_article', 'helphub_version' ) ) || is_category() ) { + return $crumbs; + } + foreach ( $crumbs as $i => $link ) { if ( str_contains( $link, 'bbp-breadcrumb-home' ) ) { $crumbs[ $i ] = str_replace( home_url(), home_url( '/forums/' ), $link );