bp_nouveau_group_locate_template_part( string $template = '' )

Locate a single group template into a specific hierarchy.

Description

Parameters

$template

(Optional) The template part to get (eg: activity, members...).

Default value: ''

Return

(string) The located template.

Source

File: bp-templates/bp-nouveau/includes/groups/functions.php

937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
function bp_nouveau_group_locate_template_part( $template = '' ) {
    $current_group = groups_get_current_group();
    $bp_nouveau    = bp_nouveau();
 
    if ( ! $template || empty( $current_group->id ) ) {
        return '';
    }
 
    // Use a global to avoid requesting the hierarchy for each template
    if ( ! isset( $bp_nouveau->groups->current_group_hierarchy ) ) {
        $bp_nouveau->groups->current_group_hierarchy = array(
            'groups/single/%s-id-' . sanitize_file_name( $current_group->id ) . '.php',
            'groups/single/%s-slug-' . sanitize_file_name( $current_group->slug ) . '.php',
        );
 
        /**
         * Check for group types and add it to the hierarchy
         */
        if ( bp_groups_get_group_types() ) {
            $current_group_type = bp_groups_get_group_type( $current_group->id );
            if ( ! $current_group_type ) {
                $current_group_type = 'none';
            }
 
            $bp_nouveau->groups->current_group_hierarchy[] = 'groups/single/%s-group-type-' . sanitize_file_name( $current_group_type ) . '.php';
        }
 
        $bp_nouveau->groups->current_group_hierarchy = array_merge( $bp_nouveau->groups->current_group_hierarchy, array(
            'groups/single/%s-status-' . sanitize_file_name( $current_group->status ) . '.php',
            'groups/single/%s.php'
        ) );
    }
 
    // Init the templates
    $templates = array();
 
    // Loop in the hierarchy to fill it for the requested template part
    foreach ( $bp_nouveau->groups->current_group_hierarchy as $part ) {
        $templates[] = sprintf( $part, sanitize_file_name( $template ) );
    }
 
    /**
     * Filters the found template parts for the group template part locating functionality.
     *
     * @since BuddyPress 3.0.0
     *
     * @param array $templates Array of found templates.
     */
    return bp_locate_template( apply_filters( 'bp_nouveau_group_locate_template_part', $templates ), false, true );
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.