bp_nouveau_member_locate_template_part( string $template = '' )
Locate a single member template into a specific hierarchy.
Description Description
Parameters Parameters
- $template
-
(Optional) The template part to get (eg: activity, groups...).
Default value: ''
Return Return
(string) The located template.
Source Source
File: bp-templates/bp-nouveau/includes/members/functions.php
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | function bp_nouveau_member_locate_template_part( $template = '' ) { $displayed_user = bp_get_displayed_user(); $bp_nouveau = bp_nouveau(); if ( ! $template || empty ( $displayed_user ->id ) ) { return '' ; } // Use a global to avoid requesting the hierarchy for each template if ( ! isset( $bp_nouveau ->members->displayed_user_hierarchy ) ) { $bp_nouveau ->members->displayed_user_hierarchy = array ( 'members/single/%s-id-' . sanitize_file_name( $displayed_user ->id ) . '.php' , 'members/single/%s-nicename-' . sanitize_file_name( $displayed_user ->userdata->user_nicename ) . '.php' , ); /* * Check for member types and add it to the hierarchy * * Make sure to register your member * type using the hook 'bp_register_member_types' */ if ( bp_get_member_types() ) { $displayed_user_member_type = bp_get_member_type( $displayed_user ->id ); if ( ! $displayed_user_member_type ) { $displayed_user_member_type = 'none' ; } $bp_nouveau ->members->displayed_user_hierarchy[] = 'members/single/%s-member-type-' . sanitize_file_name( $displayed_user_member_type ) . '.php' ; } // And the regular one $bp_nouveau ->members->displayed_user_hierarchy[] = 'members/single/%s.php' ; } $templates = array (); // Loop in the hierarchy to fill it for the requested template part foreach ( $bp_nouveau ->members->displayed_user_hierarchy as $part ) { $templates [] = sprintf( $part , $template ); } /** * Filters the found template parts for the member template part locating functionality. * * @since 3.0.0 * * @param array $templates Array of found templates. */ return bp_locate_template( apply_filters( 'bp_nouveau_member_locate_template_part' , $templates ), false, true ); } |
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |