<!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][10184] trunk/src: Improve template loading for Groups single items home 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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/10184">10184</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10184","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-04 13:47:36 +0000 (Sun, 04 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Improve template loading for Groups single items home pages.
- Make sure an activity sub navigation will be generated if the displayed group has a custom front page.
- Make sure no members sub navigation is generated if the activity component is not active and the Group has no custom front. As, in this case the home page of the group is already displaying the members template.
- Make sure some Groups single item conditional tags are behaving the right way:
- `bp_is_group_home()` is true when on the home page of the group (eg: site.url/groups/single-group/).
- `bp_is_group_activity()` is true when the activity page of the group is displayed. It can be the home page of the group or its activity page (eg: site.url/groups/single-group/activity).
- `bp_is_group_members()` is true when the members page of the group is displayed. It can be the home page of the group or its members page (eg: site.url/groups/single-group/members).
- Introduce a new conditional tag: `bp_is_group_custom_front()` to check if the home page of the group is using a custom front template.
- Introduce a new template tag `bp_groups_front_template_part()` used to choose the appropriate template to load for the home page of the group (activity, members, or the custom front).
- Introduce a template hierarchy for the `buddypress/groups/single/front.php` template so that it is possible to have different front pages according to the ID, slug or status of the Group.
- And finally make sure the introduced improvements are back compatible with themes who forgot to update their `buddypress/groups/single/home.php` and `buddypress/activity/post-form.php` templates.
Props r-a-y, boonebgorges, DJPaul, and imath :)
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/6388">#6388</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityfunctionsphp">trunk/src/bp-activity/bp-activity-functions.php</a></li>
<li><a href="#trunksrcbpcorebpcoretemplatephp">trunk/src/bp-core/bp-core-template.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupsfiltersphp">trunk/src/bp-groups/bp-groups-filters.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupsloaderphp">trunk/src/bp-groups/bp-groups-loader.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupsscreensphp">trunk/src/bp-groups/bp-groups-screens.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupstemplatephp">trunk/src/bp-groups/bp-groups-template.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacybuddypressactivitypostformphp">trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacybuddypressgroupssinglehomephp">trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacybuddypressfunctionsphp">trunk/src/bp-templates/bp-legacy/buddypress-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-functions.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-activity/bp-activity-functions.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3104,11 +3104,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
</span><span class="cx" style="display: block; padding: 0 10px"> * @uses bp_is_activity_directory() to check if the current page is the activity
</span><span class="cx" style="display: block; padding: 0 10px"> * directory.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @uses bp_is_active() to check if the group component is active.
</del><span class="cx" style="display: block; padding: 0 10px"> * @uses bp_is_group_activity() to check if on a single group, the current page
</span><span class="cx" style="display: block; padding: 0 10px"> * is the group activities.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @uses bp_is_group_home() to check if the current page is a single group home
- * page.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if activity heartbeat is enabled, otherwise false.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3119,18 +3116,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( bp_is_activity_directory() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( bp_is_activity_directory() || bp_is_group_activity() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $retval = true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( bp_is_active( 'groups') ) {
- // If no custom front, then activities are loaded in group's home
- $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
-
- if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) {
- $retval = true;
- }
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpcorebpcoretemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-template.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-core/bp-core-template.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2552,7 +2552,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return True if the current page is a group's activity page.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_is_group_activity() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $retval = false;
+
+ if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
+ $retval = true;
+ }
+
+ if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
+ $retval = true;
+ }
+
+ return $retval;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2585,7 +2595,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool True if the current page is part of a group's Members page.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_is_group_members() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $retval = false;
+
+ if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
+ $retval = true;
+ }
+
+ if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
+ $retval = true;
+ }
+
+ return $retval;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2633,6 +2653,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Is the current group page a custom front?
+ *
+ * @since 2.4.0
+ *
+ * @return bool True if the current group page is a custom front.
+ */
+function bp_is_group_custom_front() {
+ $bp = buddypress();
+ return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Is the current page the Create a Blog page?
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Eg http://example.com/sites/create/.
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupsfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-filters.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-groups/bp-groups-filters.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -269,7 +269,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $load_mentions;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $load_mentions || ( bp_is_group_activity() || bp_is_group_home() ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $load_mentions || bp_is_group_activity() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupsloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-loader.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-groups/bp-groups-loader.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -251,6 +251,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->current_group->user_has_access = true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check once if the current group has a custom front template
+ $this->current_group->front_template = bp_groups_get_front_template( $this->current_group );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set current_group to 0 to prevent debug errors
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->current_group = 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -371,6 +374,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $bp = buddypress();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
+ if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
+ $this->default_extension = 'home';
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! bp_current_action() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $bp->current_action = $this->default_extension;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -527,18 +535,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sub_nav[] = array(
- 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
- 'slug' => 'members',
- 'parent_url' => $group_link,
- 'parent_slug' => $this->current_group->slug,
- 'screen_function' => 'groups_screen_group_members',
- 'position' => 60,
- 'user_has_access' => $this->current_group->user_has_access,
- 'item_css_id' => 'members',
- 'no_access_url' => $group_link,
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) {
+ /**
+ * If the theme is using a custom front, create activity subnav.
+ */
+ if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) {
+ $sub_nav[] = array(
+ 'name' => _x( 'Activity', 'My Group screen nav', 'buddypress' ),
+ 'slug' => 'activity',
+ 'parent_url' => $group_link,
+ 'parent_slug' => $this->current_group->slug,
+ 'screen_function' => 'groups_screen_group_activity',
+ 'position' => 11,
+ 'user_has_access' => $this->current_group->user_has_access,
+ 'item_css_id' => 'activity',
+ 'no_access_url' => $group_link,
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Only add the members subnav if it's not the home's nav
+ */
+ $sub_nav[] = array(
+ 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
+ 'slug' => 'members',
+ 'parent_url' => $group_link,
+ 'parent_slug' => $this->current_group->slug,
+ 'screen_function' => 'groups_screen_group_members',
+ 'position' => 60,
+ 'user_has_access' => $this->current_group->user_has_access,
+ 'item_css_id' => 'members',
+ 'no_access_url' => $group_link,
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $sub_nav[] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => _x( 'Send Invites', 'My Group screen nav', 'buddypress' ),
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupsscreensphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-screens.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-screens.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-groups/bp-groups-screens.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -741,6 +741,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Handle the loading of a single group's activity.
+ *
+ * @since 2.4.0
+ */
+function groups_screen_group_activity() {
+
+ if ( ! bp_is_single_item() ) {
+ return false;
+ }
+
+ /**
+ * Fires before the loading of a single group's activity page.
+ *
+ * @since 2.4.0
+ */
+ do_action( 'groups_screen_group_activity' );
+
+ /**
+ * Filters the template to load for a single group's activity page.
+ *
+ * @since 2.4.0
+ *
+ * @param string $value Path to a single group's template to load.
+ */
+ bp_core_load_template( apply_filters( 'groups_screen_group_activity', 'groups/single/activity' ) );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Handle the display of a single group activity item.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function groups_screen_group_activity_permalink() {
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupstemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-template.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-groups/bp-groups-template.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4343,6 +4343,70 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Output the contents of the current group's home page.
+ *
+ * You should only use this when on a single group page.
+ *
+ * @since 2.4.0
+ */
+function bp_groups_front_template_part() {
+ $located = bp_groups_get_front_template();
+
+ if ( false !== $located ) {
+ $slug = str_replace( '.php', '', $located );
+
+ /**
+ * Let plugins adding an action to bp_get_template_part get it from here
+ *
+ * @param string $slug Template part slug requested.
+ * @param string $name Template part name requested.
+ */
+ do_action( 'get_template_part_' . $slug, $slug, false );
+
+ load_template( $located, true );
+
+ } else if ( bp_is_active( 'activity' ) ) {
+ bp_get_template_part( 'groups/single/activity' );
+
+ } else if ( bp_is_active( 'members' ) ) {
+ bp_groups_members_template_part();
+ }
+
+ return $located;
+}
+
+/**
+ * Locate a custom group front template if it exists.
+ *
+ * @since 2.4.0
+ *
+ * @param BP_Groups_Group|null $group Optional. Falls back to current group if not passed.
+ * @return string|bool Path to front template on success; boolean false on failure.
+ */
+function bp_groups_get_front_template( $group = null ) {
+ if ( ! is_a( $group, 'BP_Groups_Group' ) ) {
+ $group = groups_get_current_group();
+ }
+
+ if ( ! isset( $group->id ) ) {
+ return false;
+ }
+
+ if ( isset( $group->front_template ) ) {
+ return $group->front_template;
+ }
+
+ $template_names = apply_filters( 'bp_groups_get_front_template', array(
+ 'groups/single/front-id-' . sanitize_file_name( $group->id ) . '.php',
+ 'groups/single/front-slug-' . sanitize_file_name( $group->slug ) . '.php',
+ 'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php',
+ 'groups/single/front.php'
+ ) );
+
+ return bp_locate_template( $template_names, false, true );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Output the Group members template
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacybuddypressactivitypostformphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,7 +66,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php elseif ( bp_is_group_home() ) : ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php elseif ( bp_is_group_activity() ) : ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" />
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacybuddypressgroupssinglehomephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,18 +77,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( bp_group_is_visible() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Use custom front if one exists
- $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
- if ( ! empty( $custom_front ) ) : load_template( $custom_front, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Load appropriate front template
+ bp_groups_front_template_part();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Default to activity
- elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' );
-
- // Otherwise show members
- elseif ( bp_is_active( 'members' ) ) : bp_groups_members_template_part();
-
- endif;
-
</del><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacybuddypressfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-templates/bp-legacy/buddypress-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/buddypress-functions.php 2015-10-04 07:29:24 UTC (rev 10183)
+++ trunk/src/bp-templates/bp-legacy/buddypress-functions.php 2015-10-04 13:47:36 UTC (rev 10184)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -928,17 +928,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $activity_id = 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $item_id = 0;
+ $object = '';
+
+
+ // Try to get the item id from posted variables.
+ if ( ! empty( $_POST['item_id'] ) ) {
+ $item_id = (int) $_POST['item_id'];
+ }
+
+ // Try to get the object from posted variables.
+ if ( ! empty( $_POST['object'] ) ) {
+ $object = sanitize_key( $_POST['object'] );
+
+ // If the object is not set and we're in a group, set the item id and the object
+ } elseif ( bp_is_group() ) {
+ $item_id = bp_get_current_group_id();
+ $object = 'groups';
+ }
+
+ if ( ! $object && bp_is_active( 'activity' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( $_POST['object'] == 'groups' ) {
- if ( ! empty( $_POST['item_id'] ) && bp_is_active( 'groups' ) )
- $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( 'groups' === $object ) {
+ if ( $item_id && bp_is_active( 'groups' ) )
+ $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $item_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in bp-activity/bp-activity-actions.php */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $activity_id = apply_filters( 'bp_activity_custom_update', false, $_POST['object'], $_POST['item_id'], $_POST['content'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $activity_id = apply_filters( 'bp_activity_custom_update', false, $object, $item_id, $_POST['content'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $activity_id ) )
</span></span></pre>
</div>
</div>
</body>
</html>