<!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][9291] trunk/src: Move the Blogs and Groups create links into their directory main navs</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/9291">9291</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/9291","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>2014-12-31 13:57:38 +0000 (Wed, 31 Dec 2014)</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'>Move the Blogs and Groups create links into their directory main navs
Since <a href="http://buddypress.trac.wordpress.org/changeset/9157">r9157</a>, we have removed the create links of these two components from the title of their WordPress post object.
For version 2.2, we've decided to move them into their directory main navs. As a result, each component navigation will now display 3 links for the logged in user :
- All Groups / My Groups / Create a Group
- All Sites / My Sites / Create a Site
We are aware, this might not be the best positioning for every users, so we are also introducing two new filters to help these users to neutralize it and choose their prefered positioning.
- {{{'bp_get_group_create_nav_item'}}}
- {{{'bp_get_blog_create_nav_item'}}}
Neutralizing the positioning can be achieve by simply returning false to these filters, here's an example for the Groups component create link.
{{{add_filter( 'bp_get_group_create_nav_item', '__return_false' );}}}
See <a href="http://buddypress.trac.wordpress.org/ticket/6008">#6008</a> / <a href="http://buddypress.trac.wordpress.org/ticket/4638">#4638</a>
Props hnla, johnjamesjacoby, DJPaul, boonebgorges, modemlooper, imath</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpblogsbpblogstemplatephp">trunk/src/bp-blogs/bp-blogs-template.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupstemplatephp">trunk/src/bp-groups/bp-groups-template.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacybuddypressfunctionsphp">trunk/src/bp-templates/bp-legacy/buddypress-functions.php</a></li>
<li><a href="#trunksrcbptemplatesbplegacyjsbuddypressjs">trunk/src/bp-templates/bp-legacy/js/buddypress.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpblogsbpblogstemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-blogs/bp-blogs-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-blogs/bp-blogs-template.php 2014-12-29 22:28:28 UTC (rev 9290)
+++ trunk/src/bp-blogs/bp-blogs-template.php 2014-12-31 13:57:38 UTC (rev 9291)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1468,7 +1468,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'component' => 'blogs',
</span><span class="cx" style="display: block; padding: 0 10px"> 'link_text' => __( 'Create a Site', 'buddypress' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'link_title' => __( 'Create a Site', 'buddypress' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'link_class' => 'button blog-create bp-title-button',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'link_class' => 'blog-create no-ajax',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . trailingslashit( 'create' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'wrapper' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1484,6 +1484,60 @@
</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 Create a Site nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ */
+function bp_blog_create_nav_item() {
+ echo bp_get_blog_create_nav_item();
+}
+
+ /**
+ * Get the Create a Site nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @return string
+ */
+ function bp_get_blog_create_nav_item() {
+ // Get the create a site button
+ $create_blog_button = bp_get_blog_create_button();
+
+ // Make sure the button is available
+ if ( empty( $create_blog_button ) ) {
+ return;
+ }
+
+ $output = '<li id="blog-create-nav">' . $create_blog_button . '</li>';
+
+ return apply_filters( 'bp_get_blog_create_nav_item', $output );
+ }
+
+/**
+ * Checks if a specific theme is still filtering the Blogs directory title
+ * if so, transform the title button into a Blogs directory nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @uses bp_blog_create_nav_item() to output the Create a Site nav item
+ * @return string HTML Output
+ */
+function bp_blog_backcompat_create_nav_item() {
+ // Bail if Blogs nav item is already used by bp-legacy
+ if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) {
+ return;
+ }
+
+ // Bail if the theme is not filtering the Blogs directory title
+ if ( ! has_filter( 'bp_blogs_directory_header' ) ) {
+ return;
+ }
+
+ bp_blog_create_nav_item();
+}
+add_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item', 1000 );
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Output button for visiting a blog in a loop.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see bp_get_blogs_visit_blog_button() for description of arguments.
</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 2014-12-29 22:28:28 UTC (rev 9290)
+++ trunk/src/bp-groups/bp-groups-template.php 2014-12-31 13:57:38 UTC (rev 9291)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2854,7 +2854,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'component' => 'groups',
</span><span class="cx" style="display: block; padding: 0 10px"> 'link_text' => __( 'Create a Group', 'buddypress' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'link_title' => __( 'Create a Group', 'buddypress' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'link_class' => 'button group-create bp-title-button',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'link_class' => 'group-create no-ajax',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'link_href' => trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_groups_root_slug() ) . trailingslashit( 'create' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'wrapper' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2863,6 +2863,60 @@
</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 Create a Group nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ */
+function bp_group_create_nav_item() {
+ echo bp_get_group_create_nav_item();
+}
+
+ /**
+ * Get the Create a Group nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @return string
+ */
+ function bp_get_group_create_nav_item() {
+ // Get the create a group button
+ $create_group_button = bp_get_group_create_button();
+
+ // Make sure the button is available
+ if ( empty( $create_group_button ) ) {
+ return;
+ }
+
+ $output = '<li id="group-create-nav">' . $create_group_button . '</li>';
+
+ return apply_filters( 'bp_get_group_create_nav_item', $output );
+ }
+
+/**
+ * Checks if a specific theme is still filtering the Groups directory title
+ * if so, transform the title button into a Groups directory nav item.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @uses bp_group_create_nav_item() to output the create a Group nav item
+ * @return string HTML Output
+ */
+function bp_group_backcompat_create_nav_item() {
+ // Bail if the Groups nav item is already used by bp-legacy
+ if ( has_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 ) ) {
+ return;
+ }
+
+ // Bail if the theme is not filtering the Groups directory title
+ if ( ! has_filter( 'bp_groups_directory_header' ) ) {
+ return;
+ }
+
+ bp_group_create_nav_item();
+}
+add_action( 'bp_groups_directory_group_filter', 'bp_group_backcompat_create_nav_item', 1000 );
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Prints a message if the group is not visible to the current user (it is a
</span><span class="cx" style="display: block; padding: 0 10px"> * hidden or private group, and the user does not have access).
</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 2014-12-29 22:28:28 UTC (rev 9290)
+++ trunk/src/bp-templates/bp-legacy/buddypress-functions.php 2014-12-31 13:57:38 UTC (rev 9291)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,17 +108,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Group buttons
</span><span class="cx" style="display: block; padding: 0 10px"> if ( bp_is_active( 'groups' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 );
- add_action( 'bp_group_header_actions', 'bp_group_new_topic_button', 20 );
- add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
- add_filter( 'bp_groups_directory_header', 'bp_legacy_theme_group_create_button' );
- add_filter( 'bp_blogs_directory_header', 'bp_legacy_theme_blog_create_button' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 );
+ add_action( 'bp_group_header_actions', 'bp_group_new_topic_button', 20 );
+ add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
+ add_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 );
</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"> // Blog button
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( bp_is_active( 'blogs' ) )
- add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( bp_is_active( 'blogs' ) ) {
+ add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' );
+ add_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</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"> /** Notices ***********************************************************/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -449,6 +451,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * the behavior of bp-default.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since BuddyPress (2.0.0)
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @todo Deprecate
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $title Groups directory title.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -458,12 +461,28 @@
</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">+ * Add the Create a Group nav to the Groups directory navigation.
+ *
+ * bp-legacy puts the Create a Group nav at the last position of
+ * the Groups directory navigation.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @uses bp_group_create_nav_item() to output the create a Group nav item
+ * @return string
+ */
+function bp_legacy_theme_group_create_nav() {
+ bp_group_create_nav_item();
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Add the Create a Site button to the Sites directory title.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * bp-legacy puts the Create a Site button into the page title, to mimic
</span><span class="cx" style="display: block; padding: 0 10px"> * the behavior of bp-default.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since BuddyPress (2.0.0)
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @todo Deprecate
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $title Sites directory title.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -471,7 +490,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_legacy_theme_blog_create_button( $title ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $title . ' ' . bp_get_blog_create_button();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Add the Create a Site nav to the Sites directory navigation.
+ *
+ * bp-legacy puts the Create a Site nav at the last position of
+ * the Sites directory navigation.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @uses bp_blog_create_nav_item() to output the Create a Site nav item
+ * @return string
+ */
+function bp_legacy_theme_blog_create_nav() {
+ bp_blog_create_nav_item();
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * This function looks scarier than it actually is. :)
</span><span class="cx" style="display: block; padding: 0 10px"> * Each object loop (activity/members/groups/blogs/forums) contains default
</span><span class="cx" style="display: block; padding: 0 10px"> * parameters to show specific information based on the page we are currently
</span></span></pre></div>
<a id="trunksrcbptemplatesbplegacyjsbuddypressjs"></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/js/buddypress.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-templates/bp-legacy/js/buddypress.js 2014-12-29 22:28:28 UTC (rev 9290)
+++ trunk/src/bp-templates/bp-legacy/js/buddypress.js 2014-12-31 13:57:38 UTC (rev 9291)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -835,7 +835,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
</span><span class="cx" style="display: block; padding: 0 10px"> jq('div.item-list-tabs').on( 'click', function(event) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( jq(this).hasClass('no-ajax') ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( jq(this).hasClass('no-ajax') || jq( event.target ).hasClass('no-ajax') ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>