<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [2712] trunk:
  Made the ajax_querystring function a core template tag that can be filtered by the active theme
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2712</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-02-12 18:52:58 +0000 (Fri, 12 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Made the ajax_querystring function a core template tag that can be filtered by the active theme. This will allow the bp-default templates to be copied into another WordPress theme without having to copy anything in functions.php.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoretemplatetagsphp">trunk/bp-core/bp-core-templatetags.php</a></li>
<li><a href="#trunkbpthemesbpdefault_incajaxphp">trunk/bp-themes/bp-default/_inc/ajax.php</a></li>
<li><a href="#trunkbpthemesbpdefaultactivityactivityloopphp">trunk/bp-themes/bp-default/activity/activity-loop.php</a></li>
<li><a href="#trunkbpthemesbpdefaultblogsblogsloopphp">trunk/bp-themes/bp-default/blogs/blogs-loop.php</a></li>
<li><a href="#trunkbpthemesbpdefaultforumsforumsloopphp">trunk/bp-themes/bp-default/forums/forums-loop.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
<li><a href="#trunkbpthemesbpdefaultgroupsgroupsloopphp">trunk/bp-themes/bp-default/groups/groups-loop.php</a></li>
<li><a href="#trunkbpthemesbpdefaultmembersmembersloopphp">trunk/bp-themes/bp-default/members/members-loop.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoretemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-templatetags.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-templatetags.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-core/bp-core-templatetags.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -1266,6 +1266,24 @@
</span><span class="cx">         return apply_filters( 'bp_get_option', $bp-&gt;site_options[$option_name] );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Allow templates to pass parameters directly into the template loops via AJAX
+ *
+ * For the most part this will be filtered in a theme's functions.php for example
+ * in the default theme it is filtered via bp_dtheme_ajax_querystring()
+ *
+ * By using this template tag in the templates it will stop them from showing errors
+ * if someone copies the templates from the default theme into another WordPress theme
+ * without coping the functions from functions.php.
+ */
+function bp_ajax_querystring( $object = false ) {
+        global $bp;
+
+        $bp-&gt;ajax_querystring = apply_filters( 'bp_ajax_querystring', $query_string, $object );
+        return $bp-&gt;ajax_querystring;
+}
+
+
</ins><span class="cx"> /*** CUSTOM LOOP TEMPLATE CLASSES *******************/
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_incajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/ajax.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/ajax.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/_inc/ajax.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx">  * to override the parameters sent. That way we can change the results returned without reloading the page.
</span><span class="cx">  * By using cookies we can also make sure that user settings are retained across page loads.
</span><span class="cx">  */
</span><del>-function bp_dtheme_ajax_querystring( $object = false ) {
</del><ins>+function bp_dtheme_ajax_querystring( $query_string, $object ) {
</ins><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         if ( empty( $object ) )
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> 
</span><span class="cx">         return apply_filters( 'bp_dtheme_ajax_querystring', $query_string, $object, $_BP_COOKIE['bp-' . $object . '-filter'], $_BP_COOKIE['bp-' . $object . '-scope'], $_BP_COOKIE['bp-' . $object . '-page'], $_BP_COOKIE['bp-' . $object . '-search-terms'], $_BP_COOKIE['bp-' . $object . '-extras'] );
</span><span class="cx"> }
</span><ins>+add_filter( 'bp_ajax_querystring', 'bp_dtheme_ajax_querystring', 10, 2 );
</ins><span class="cx"> 
</span><span class="cx"> /* This function will simply load the template loop for the current object. On an AJAX request */
</span><span class="cx"> function bp_dtheme_object_template_loader() {
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivityactivityloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/activity-loop.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/activity-loop.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/activity/activity-loop.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php do_action( 'bp_before_activity_loop' ) ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( bp_has_activities( bp_dtheme_ajax_querystring( 'activity' ) ) ) : ?&gt;
</del><ins>+&lt;?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;?php /* Show pagination if JS is not enabled, since the &quot;Load More&quot; link will do nothing */ ?&gt;
</span><span class="cx">         &lt;noscript&gt;
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultblogsblogsloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/blogs/blogs-loop.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/blogs/blogs-loop.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/blogs/blogs-loop.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php do_action( 'bp_before_blogs_loop' ) ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( bp_has_blogs( bp_dtheme_ajax_querystring( 'blogs' ) ) ) : ?&gt;
</del><ins>+&lt;?php if ( bp_has_blogs( bp_ajax_querystring( 'blogs' ) ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;pagination&quot;&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultforumsforumsloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/forums/forums-loop.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/forums/forums-loop.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/forums/forums-loop.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-&lt;?php if ( bp_has_forum_topics( bp_dtheme_ajax_querystring( 'forums' ) ) ) : ?&gt;
</del><ins>+&lt;?php if ( bp_has_forum_topics( bp_ajax_querystring( 'forums' ) ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;pagination&quot;&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/functions.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -201,7 +201,17 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'init', 'bp_dtheme_add_custom_header_support' );
</span><span class="cx"> 
</span><del>-/* Show a notice to the user in wp-admin when the theme is activated */
</del><ins>+/* Remove r */
+function bp_dtheme_remove_redundant() {
+        global $bp;
+
+        /* Remove the navigation options we do not need in this theme. */
+        bp_core_remove_subnav_item( $bp-&gt;blogs-&gt;slug, 'my-blogs' );
+        bp_core_remove_subnav_item( $bp-&gt;blogs-&gt;slug, 'recent-posts' );
+        bp_core_remove_subnav_item( $bp-&gt;blogs-&gt;slug, 'recent-comments' );
+}
+add_action( 'init', 'bp_dtheme_remove_redundant' );
+
</ins><span class="cx"> function bp_dtheme_show_notice() { ?&gt;
</span><span class="cx">         &lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;
</span><span class="cx">                 &lt;p&gt;&lt;?php printf( __( 'Theme activated! This theme contains &lt;a href=&quot;%s&quot;&gt;custom header image&lt;/a&gt; support and &lt;a href=&quot;%s&quot;&gt;sidebar widgets&lt;/a&gt;.', 'buddypress' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?&gt;&lt;/p&gt;
</span><span class="lines">@@ -210,8 +220,6 @@
</span><span class="cx">         &lt;style type=&quot;text/css&quot;&gt;#message2, #message0 { display: none; }&lt;/style&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx"> }
</span><del>-if ( is_admin() &amp;&amp; isset($_GET['activated'] ) &amp;&amp; $pagenow == &quot;themes.php&quot; )
-        add_action( 'admin_notices', 'bp_dtheme_show_notice' );
</del><span class="cx"> 
</span><span class="cx"> /* Add words that we need to use in JS to the end of the page so they can be translated and still used. */
</span><span class="cx"> function bp_dtheme_js_terms() { ?&gt;
</span><span class="lines">@@ -229,4 +237,11 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp_footer', 'bp_dtheme_js_terms' );
</span><span class="cx"> 
</span><ins>+
+/* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */
+if ( is_admin() &amp;&amp; isset($_GET['activated'] ) &amp;&amp; $pagenow == &quot;themes.php&quot; ) {
+        add_action( 'admin_notices', 'bp_dtheme_show_notice' );
+}
+
+
</ins><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultgroupsgroupsloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/groups/groups-loop.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/groups/groups-loop.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/groups/groups-loop.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php do_action( 'bp_before_groups_loop' ) ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( bp_has_groups( bp_dtheme_ajax_querystring( 'groups' ) ) ) : ?&gt;
</del><ins>+&lt;?php if ( bp_has_groups( bp_ajax_querystring( 'groups' ) ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;pagination&quot;&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultmembersmembersloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/members/members-loop.php (2711 => 2712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/members/members-loop.php        2010-02-12 18:23:59 UTC (rev 2711)
+++ trunk/bp-themes/bp-default/members/members-loop.php        2010-02-12 18:52:58 UTC (rev 2712)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php do_action( 'bp_before_members_loop' ) ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( bp_has_members( bp_dtheme_ajax_querystring( 'members' ) ) ) : ?&gt;
</del><ins>+&lt;?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;pagination&quot;&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>