| 448 | | $title = bp_get_displayed_user_fullname(); |
| | 448 | // Get the component's ID to try and get its name |
| | 449 | $component_id = $component_name = bp_current_component(); |
| | 450 | |
| | 451 | // Use the component nav name |
| | 452 | if ( ! empty( $bp->bp_nav[$component_id] ) ) { |
| | 453 | // Remove counts that are added by the nav item |
| | 454 | $span = strpos( $bp->bp_nav[$component_id]['name'], '<span' ); |
| | 455 | if ( false !== $span ) { |
| | 456 | $component_name = substr( $bp->bp_nav[$component_id]['name'], 0, $span ); |
| | 457 | |
| | 458 | } else { |
| | 459 | $component_name = $bp->bp_nav[$component_id]['name']; |
| | 460 | } |
| | 461 | |
| | 462 | // Fall back on the component ID |
| | 463 | } elseif ( ! empty( $bp->{$component_id}->id ) ) { |
| | 464 | $component_name = $bp->{$component_id}->id; |
| | 465 | } |
| | 466 | |
| | 467 | // Append action name if we're on a member component sub-page |
| | 468 | if ( ! empty( $bp->bp_options_nav[$component_id][bp_current_action()]['name'] ) && ! empty( $bp->canonical_stack['action'] ) ) { |
| | 469 | $component_subnav_name = "{$bp->bp_options_nav[bp_current_component()][bp_current_action()]['name']}"; |
| | 470 | } else { |
| | 471 | $component_subnav_name = ''; |
| | 472 | } |
| | 473 | |
| | 474 | // If on the user profile's landing page, just use the fullname |
| | 475 | if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) { |
| | 476 | $title = bp_get_displayed_user_fullname(); |
| | 477 | |
| | 478 | // Use component name on member pages |
| | 479 | } else { |
| | 480 | // If we have a subnav name, add it separately for localization |
| | 481 | if ( ! empty( $component_subnav_name ) ) { |
| | 482 | // translators: construct the page title. 1 = user name, 2 = component name, 3 = seperator, 4 = component subnav name |
| | 483 | $title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( $component_name ), $sep, $component_subnav_name ) ); |
| | 484 | |
| | 485 | } else { |
| | 486 | // translators: construct the page title. 1 = user name, 2 = component name, 3 = seperator |
| | 487 | $title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), ucwords( $component_name ), $sep ) ); |
| | 488 | } |
| | 489 | } |