Skip to:
Content

BuddyPress.org

Changeset 8090


Ignore:
Timestamp:
03/09/2014 02:38:24 PM (6 years ago)
Author:
boonebgorges
Message:

Improve strings used for <title> and header of directory pages

Our legacy method for creating directory titles involved concatenating the
component name into '% Directory', which did not work well in languages where
a term like 'Groups Directory' would be translated into a single word. In
addition, there was inconistency between the <title> element on directory pages
and the header element used in the page body.

This changeset introduces a 'directory_title' parameter to BP_Core_Component,
so that directories can register a fully localizable string as the title/
header for directories.

To avoid filter name conflicts, the filter names associated with the headers
on group and blog directory pages were changed to _directory_header. See r7942,

See #4726, #4630

Fixes #4631

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-loader.php

    r7854 r8090  
    107107            'root_slug'             => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
    108108            'has_directory'         => true,
     109            'directory_title'       => _x( 'Sitewide Activity', 'component directory title', 'buddypress' ),
    109110            'notification_callback' => 'bp_activity_format_notifications',
    110111            'search_string'         => __( 'Search Activity...', 'buddypress' ),
  • trunk/bp-activity/bp-activity-screens.php

    r7926 r8090  
    382382        bp_theme_compat_reset_post( array(
    383383            'ID'             => 0,
    384             'post_title'     => __( 'Sitewide Activity', 'buddypress' ),
     384            'post_title'     => bp_get_directory_title( 'activity' ),
    385385            'post_author'    => 0,
    386386            'post_date'      => 0,
  • trunk/bp-blogs/bp-blogs-screens.php

    r7942 r8090  
    142142    public function directory_dummy_post() {
    143143
    144         $title = apply_filters( 'bp_blogs_directory_title', __( 'Sites', 'buddypress' ) );
     144        $title = apply_filters( 'bp_blogs_directory_header', __( 'Sites', 'buddypress' ) );
    145145
    146146        bp_theme_compat_reset_post( array(
  • trunk/bp-core/bp-core-component.php

    r7839 r8090  
    216216            'root_slug'             => $default_root_slug,
    217217            'has_directory'         => false,
     218            'directory_title'       => '',
    218219            'notification_callback' => '',
    219220            'search_string'         => '',
     
    230231        // Does this component have a top-level directory?
    231232        $this->has_directory         = apply_filters( 'bp_' . $this->id . '_has_directory',         $r['has_directory']         );
     233
     234        // Does this component have a top-level directory?
     235        $this->directory_title       = apply_filters( 'bp_' . $this->id . '_directory_title',       $r['directory_title']         );
    232236
    233237        // Search string
  • trunk/bp-core/bp-core-filters.php

    r8033 r8090  
    432432    // An index or directory
    433433    } elseif ( bp_is_directory() ) {
    434         if ( !bp_current_component() ) {
    435             $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
     434
     435        $current_component = bp_current_component();
     436
     437        // No current component (when does this happen?)
     438        if ( empty( $current_component ) ) {
     439            $title = _x( 'Directory', 'component directory title', 'buddypress' );
    436440        } else {
    437             $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
     441            $title = bp_get_directory_title( $current_component );
    438442        }
    439443
  • trunk/bp-core/bp-core-template.php

    r8068 r8090  
    8282
    8383    echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
     84}
     85
     86/**
     87 * Get the directory title for a component.
     88 *
     89 * Used for the <title> element and the page header on the component directory
     90 * page.
     91 *
     92 * @since BuddyPress (2.0.0)
     93 *
     94 * @return string
     95 */
     96function bp_get_directory_title( $component = '' ) {
     97    $title = '';
     98
     99    // Use the string provided by the component
     100    if ( isset( buddypress()->{$component}->directory_title ) ) {
     101        $title = buddypress()->{$component}->directory_title;
     102
     103    // If none is found, concatenate
     104    } else if ( isset( buddypress()->{$component}->name ) ) {
     105        $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
     106    }
     107
     108    return apply_filters( 'bp_get_directory_title', $title, $component );
    84109}
    85110
  • trunk/bp-groups/bp-groups-loader.php

    r8057 r8090  
    148148            'root_slug'             => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
    149149            'has_directory'         => true,
     150            'directory_title'       => _x( 'Groups', 'component directory title', 'buddypress' ),
    150151            'notification_callback' => 'groups_format_notifications',
    151152            'search_string'         => __( 'Search Groups...', 'buddypress' ),
  • trunk/bp-groups/bp-groups-screens.php

    r7942 r8090  
    10221022    public function directory_dummy_post() {
    10231023
    1024         $title = apply_filters( 'bp_groups_directory_title', __( 'Groups', 'buddypress' ) );
     1024        $title = apply_filters( 'bp_groups_directory_header', bp_get_directory_title( 'groups' ) );
    10251025
    10261026        bp_theme_compat_reset_post( array(
  • trunk/bp-members/bp-members-loader.php

    r7860 r8090  
    7373            'root_slug'     => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
    7474            'has_directory' => true,
     75            'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),
    7576            'global_tables' => array(
    7677                'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
  • trunk/bp-members/bp-members-screens.php

    r7926 r8090  
    364364        bp_theme_compat_reset_post( array(
    365365            'ID'             => 0,
    366             'post_title'     => __( 'Members', 'buddypress' ),
     366            'post_title'     => bp_get_directory_title( 'members' ),
    367367            'post_author'    => 0,
    368368            'post_date'      => 0,
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r8088 r8090  
    112112                add_action( 'bp_group_header_actions',     'bp_group_new_topic_button',      20 );
    113113                add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
    114                 add_filter( 'bp_groups_directory_title',   'bp_legacy_theme_group_create_button' );
    115                 add_filter( 'bp_blogs_directory_title',    'bp_legacy_theme_blog_create_button' );
     114                add_filter( 'bp_groups_directory_header',  'bp_legacy_theme_group_create_button' );
     115                add_filter( 'bp_blogs_directory_header',   'bp_legacy_theme_blog_create_button' );
    116116            }
    117117
Note: See TracChangeset for help on using the changeset viewer.