<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][8090] trunk: Improve strings used for <title> and header of directory pages</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/8090">8090</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2014-03-09 14:38:24 +0000 (Sun, 09 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <a href="http://buddypress.trac.wordpress.org/changeset/7942">r7942</a>,
See <a href="http://buddypress.trac.wordpress.org/ticket/4726">#4726</a>, <a href="http://buddypress.trac.wordpress.org/ticket/4630">#4630</a>
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4631">#4631</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityloaderphp">trunk/bp-activity/bp-activity-loader.php</a></li>
<li><a href="#trunkbpactivitybpactivityscreensphp">trunk/bp-activity/bp-activity-screens.php</a></li>
<li><a href="#trunkbpblogsbpblogsscreensphp">trunk/bp-blogs/bp-blogs-screens.php</a></li>
<li><a href="#trunkbpcorebpcorecomponentphp">trunk/bp-core/bp-core-component.php</a></li>
<li><a href="#trunkbpcorebpcorefiltersphp">trunk/bp-core/bp-core-filters.php</a></li>
<li><a href="#trunkbpcorebpcoretemplatephp">trunk/bp-core/bp-core-template.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsloaderphp">trunk/bp-groups/bp-groups-loader.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsscreensphp">trunk/bp-groups/bp-groups-screens.php</a></li>
<li><a href="#trunkbpmembersbpmembersloaderphp">trunk/bp-members/bp-members-loader.php</a></li>
<li><a href="#trunkbpmembersbpmembersscreensphp">trunk/bp-members/bp-members-screens.php</a></li>
<li><a href="#trunkbptemplatesbplegacybuddypressfunctionsphp">trunk/bp-templates/bp-legacy/buddypress-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-loader.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-loader.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-activity/bp-activity-loader.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -106,6 +106,7 @@
</span><span class="cx"> 'slug' => BP_ACTIVITY_SLUG,
</span><span class="cx"> 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
</span><span class="cx"> 'has_directory' => true,
</span><ins>+ 'directory_title' => _x( 'Sitewide Activity', 'component directory title', 'buddypress' ),
</ins><span class="cx"> 'notification_callback' => 'bp_activity_format_notifications',
</span><span class="cx"> 'search_string' => __( 'Search Activity...', 'buddypress' ),
</span><span class="cx"> 'global_tables' => $global_tables,
</span></span></pre></div>
<a id="trunkbpactivitybpactivityscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-screens.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-screens.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-activity/bp-activity-screens.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -381,7 +381,7 @@
</span><span class="cx"> public function directory_dummy_post() {
</span><span class="cx"> bp_theme_compat_reset_post( array(
</span><span class="cx"> 'ID' => 0,
</span><del>- 'post_title' => __( 'Sitewide Activity', 'buddypress' ),
</del><ins>+ 'post_title' => bp_get_directory_title( 'activity' ),
</ins><span class="cx"> 'post_author' => 0,
</span><span class="cx"> 'post_date' => 0,
</span><span class="cx"> 'post_content' => '',
</span></span></pre></div>
<a id="trunkbpblogsbpblogsscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs/bp-blogs-screens.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs/bp-blogs-screens.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-blogs/bp-blogs-screens.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -141,7 +141,7 @@
</span><span class="cx"> */
</span><span class="cx"> public function directory_dummy_post() {
</span><span class="cx">
</span><del>- $title = apply_filters( 'bp_blogs_directory_title', __( 'Sites', 'buddypress' ) );
</del><ins>+ $title = apply_filters( 'bp_blogs_directory_header', __( 'Sites', 'buddypress' ) );
</ins><span class="cx">
</span><span class="cx"> bp_theme_compat_reset_post( array(
</span><span class="cx"> 'ID' => 0,
</span></span></pre></div>
<a id="trunkbpcorebpcorecomponentphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-component.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-component.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-core/bp-core-component.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -215,6 +215,7 @@
</span><span class="cx"> 'slug' => $this->id,
</span><span class="cx"> 'root_slug' => $default_root_slug,
</span><span class="cx"> 'has_directory' => false,
</span><ins>+ 'directory_title' => '',
</ins><span class="cx"> 'notification_callback' => '',
</span><span class="cx"> 'search_string' => '',
</span><span class="cx"> 'global_tables' => '',
</span><span class="lines">@@ -230,6 +231,9 @@
</span><span class="cx"> // Does this component have a top-level directory?
</span><span class="cx"> $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
</span><span class="cx">
</span><ins>+ // Does this component have a top-level directory?
+ $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
+
</ins><span class="cx"> // Search string
</span><span class="cx"> $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpcorebpcorefiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-filters.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-filters.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-core/bp-core-filters.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -431,10 +431,14 @@
</span><span class="cx">
</span><span class="cx"> // An index or directory
</span><span class="cx"> } elseif ( bp_is_directory() ) {
</span><del>- if ( !bp_current_component() ) {
- $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
</del><ins>+
+ $current_component = bp_current_component();
+
+ // No current component (when does this happen?)
+ if ( empty( $current_component ) ) {
+ $title = _x( 'Directory', 'component directory title', 'buddypress' );
</ins><span class="cx"> } else {
</span><del>- $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );
</del><ins>+ $title = bp_get_directory_title( $current_component );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Sign up page
</span></span></pre></div>
<a id="trunkbpcorebpcoretemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-template.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-template.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-core/bp-core-template.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -83,6 +83,31 @@
</span><span class="cx"> echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Get the directory title for a component.
+ *
+ * Used for the <title> element and the page header on the component directory
+ * page.
+ *
+ * @since BuddyPress (2.0.0)
+ *
+ * @return string
+ */
+function bp_get_directory_title( $component = '' ) {
+ $title = '';
+
+ // Use the string provided by the component
+ if ( isset( buddypress()->{$component}->directory_title ) ) {
+ $title = buddypress()->{$component}->directory_title;
+
+ // If none is found, concatenate
+ } else if ( isset( buddypress()->{$component}->name ) ) {
+ $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
+ }
+
+ return apply_filters( 'bp_get_directory_title', $title, $component );
+}
+
</ins><span class="cx"> /** Avatars *******************************************************************/
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-loader.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-loader.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-groups/bp-groups-loader.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx"> 'slug' => BP_GROUPS_SLUG,
</span><span class="cx"> 'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
</span><span class="cx"> 'has_directory' => true,
</span><ins>+ 'directory_title' => _x( 'Groups', 'component directory title', 'buddypress' ),
</ins><span class="cx"> 'notification_callback' => 'groups_format_notifications',
</span><span class="cx"> 'search_string' => __( 'Search Groups...', 'buddypress' ),
</span><span class="cx"> 'global_tables' => $global_tables,
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-screens.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-screens.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-groups/bp-groups-screens.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -1021,7 +1021,7 @@
</span><span class="cx"> */
</span><span class="cx"> public function directory_dummy_post() {
</span><span class="cx">
</span><del>- $title = apply_filters( 'bp_groups_directory_title', __( 'Groups', 'buddypress' ) );
</del><ins>+ $title = apply_filters( 'bp_groups_directory_header', bp_get_directory_title( 'groups' ) );
</ins><span class="cx">
</span><span class="cx"> bp_theme_compat_reset_post( array(
</span><span class="cx"> 'ID' => 0,
</span></span></pre></div>
<a id="trunkbpmembersbpmembersloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-loader.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-loader.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-members/bp-members-loader.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> 'slug' => BP_MEMBERS_SLUG,
</span><span class="cx"> 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
</span><span class="cx"> 'has_directory' => true,
</span><ins>+ 'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),
</ins><span class="cx"> 'global_tables' => array(
</span><span class="cx"> 'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
</span><span class="cx"> ),
</span></span></pre></div>
<a id="trunkbpmembersbpmembersscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-screens.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-screens.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-members/bp-members-screens.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx"> public function directory_dummy_post() {
</span><span class="cx"> bp_theme_compat_reset_post( array(
</span><span class="cx"> 'ID' => 0,
</span><del>- 'post_title' => __( 'Members', 'buddypress' ),
</del><ins>+ 'post_title' => bp_get_directory_title( 'members' ),
</ins><span class="cx"> 'post_author' => 0,
</span><span class="cx"> 'post_date' => 0,
</span><span class="cx"> 'post_content' => '',
</span></span></pre></div>
<a id="trunkbptemplatesbplegacybuddypressfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-templates/bp-legacy/buddypress-functions.php (8089 => 8090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-templates/bp-legacy/buddypress-functions.php 2014-03-09 14:35:17 UTC (rev 8089)
+++ trunk/bp-templates/bp-legacy/buddypress-functions.php 2014-03-09 14:38:24 UTC (rev 8090)
</span><span class="lines">@@ -111,8 +111,8 @@
</span><span class="cx"> add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 );
</span><span class="cx"> add_action( 'bp_group_header_actions', 'bp_group_new_topic_button', 20 );
</span><span class="cx"> add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
</span><del>- add_filter( 'bp_groups_directory_title', 'bp_legacy_theme_group_create_button' );
- add_filter( 'bp_blogs_directory_title', 'bp_legacy_theme_blog_create_button' );
</del><ins>+ add_filter( 'bp_groups_directory_header', 'bp_legacy_theme_group_create_button' );
+ add_filter( 'bp_blogs_directory_header', 'bp_legacy_theme_blog_create_button' );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Blog button
</span></span></pre>
</div>
</div>
</body>
</html>