Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/22/2014 02:31:06 AM (9 years ago)
Author:
r-a-y
Message:

Core: Make page title on member pages unique.

This commit partially reverts r9105, which made the <title> element the
same across all member pages, which goes against SEO conventions.

This commit does the following:

  • When on a member's landing page (eg. example.com/members/admin/), the page title will be admin | {SITE NAME}.
  • Uses the profile navigation name in the page title instead of the component's admin title. For example, when on example.com/members/admin/profile/, the page title will be 'admin | Profile | {SITE NAME}' instead of 'admin | Extended Profiles | {SITE NAME}'.
  • Adds the profile subnav name in the page title when on a member component sub-page. For example, when on example.com/members/admin/activity/mentions/, the page title will be admin | Activity | Mentions | {SITE NAME}.

Fixes #5838.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-filters.php

    r9243 r9249  
    446446    // Displayed user
    447447    if ( bp_get_displayed_user_fullname() && ! is_404() ) {
    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 - 1 );
     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 = ucwords( $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[ $component_id ][ 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(), $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(), $component_name, $sep ) );
     488            }
     489        }
    449490
    450491    // A single group
Note: See TracChangeset for help on using the changeset viewer.