Making WordPress.org

Changeset 15532


Ignore:
Timestamp:
11/10/2026 08:44:28 PM (6 hours ago)
Author:
obenland
Message:

HelpHub: Point article breadcrumbs at Support and show the category

Props obenland, chaton666.
Closes ​https://github.com/WordPress/wordpress.org/pull/1225.
Fixes #7703.

File:
1 edited

Legend:

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

    r15484 r15532  
    408408        $args['home_text']       = __( 'Forums', 'wporg-forums' );
    409409
     410        // HelpHub pages aren't part of the forums.
     411        if ( is_singular( array( 'helphub_article', 'helphub_version' ) ) || is_category() ) {
     412                $args['home_text'] = esc_html__( 'Support', 'wporg-forums' );
     413        }
     414
    410415        // Forum root
    411416        $args['include_root']    = false;
    … …  
    416421        $args['current_after']   = '</span>';
    417422
     423        // bbPress would use the title of the first post in the archive.
     424        if ( is_category() ) {
     425                $args['current_text'] = esc_html( single_cat_title( '', false ) );
     426        }
     427
    418428        return $args;
    419429}
    … …  
    423433        'bbp_breadcrumbs',
    424434        /**
    425          * Filters the breadcrumbs to replace the home URL with the forums page.
     435         * Filters the breadcrumbs to replace the home URL with the forums page,
     436         * and to add the category to HelpHub articles.
    426437         */
    427438        function( $crumbs ) {
     439                if ( is_singular( 'helphub_article' ) ) {
     440                        $categories = get_the_category( get_queried_object_id() );
     441
     442                        if ( $categories ) {
     443                                $category_crumb = sprintf(
     444                                        '<a href="%1$s" class="bbp-breadcrumb-category">%2$s</a>',
     445                                        esc_url( get_category_link( $categories[0] ) ),
     446                                        esc_html( $categories[0]->name )
     447                                );
     448                                array_splice( $crumbs, 1, 0, $category_crumb );
     449                        }
     450                }
     451
     452                if ( is_singular( array( 'helphub_article', 'helphub_version' ) ) || is_category() ) {
     453                        return $crumbs;
     454                }
     455
    428456                foreach ( $crumbs as $i => $link ) {
    429457                        if ( str_contains( $link, 'bbp-breadcrumb-home' ) ) {
Note: See TracChangeset for help on using the changeset viewer.