<!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] [2224] trunk: Adding theme options page,
and ability to show blog posts or activity stream on the front page.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2224</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-12-30 10:15:57 +0000 (Wed, 30 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Adding theme options page, and ability to show blog posts or activity stream on the front page.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpcorebpcoretemplatetagsphp">trunk/bp-core/bp-core-templatetags.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
<li><a href="#trunkbpthemesbpdefaultcommentsphp">trunk/bp-themes/bp-default/comments.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
<li><a href="#trunkbpthemesbpdefaultheaderphp">trunk/bp-themes/bp-default/header.php</a></li>
<li><a href="#trunkbpthemesbpdefaulthomephp">trunk/bp-themes/bp-default/home.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-activity.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -105,7 +105,19 @@
</span><span class="cx"> add_action( 'plugins_loaded', 'bp_activity_setup_nav' );
</span><span class="cx"> add_action( 'admin_menu', 'bp_activity_setup_nav' );
</span><span class="cx">
</span><ins>+function bp_activity_directory_activity_setup() {
+        global $bp;
</ins><span class="cx">
</span><ins>+        if ( $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) {
+                $bp->is_directory = true;
+
+                do_action( 'bp_activity_directory_activity_setup' );
+                bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) );
+        }
+}
+add_action( 'wp', 'bp_activity_directory_activity_setup', 2 );
+
+
</ins><span class="cx"> /********************************************************************************
</span><span class="cx"> * Screen Functions
</span><span class="cx"> *
</span></span></pre></div>
<a id="trunkbpcorebpcoretemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-templatetags.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-templatetags.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-core/bp-core-templatetags.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -826,15 +826,15 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_is_blog_page() {
</span><del>-        global $bp, $is_member_page;
</del><ins>+        global $bp, $is_member_page, $wp_query;
</ins><span class="cx">
</span><span class="cx">         if ( $bp->current_component == BP_HOME_BLOG_SLUG )
</span><span class="cx">                 return true;
</span><span class="cx">
</span><del>-        if ( !$is_member_page && $bp->current_component == $bp->default_component )
</del><ins>+        if ( $wp_query->is_home && !$bp->is_directory )
</ins><span class="cx">                 return true;
</span><span class="cx">
</span><del>-        if ( ( !$is_member_page && !in_array( $bp->current_component, $bp->root_components ) ) )
</del><ins>+        if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory )
</ins><span class="cx">                 return true;
</span><span class="cx">
</span><span class="cx">         return false;
</span><span class="lines">@@ -890,10 +890,10 @@
</span><span class="cx"> function bp_is_page($page) {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><del>-        if ( $bp->displayed_user->id || $bp->is_single_item )
-                return false;
</del><ins>+        if ( !$bp->displayed_user->id && $bp->current_component == $page )
+                return true;
</ins><span class="cx">
</span><del>-        if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
</del><ins>+        if ( 'home' == $page && !$bp->current_component )
</ins><span class="cx">                 return true;
</span><span class="cx">
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-core.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">
</span><span class="cx">         $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
</span><span class="cx">
</span><del>-        if ( !$bp->current_component )
</del><ins>+        if ( !$bp->current_component && $bp->displayed_user->id )
</ins><span class="cx">                 $bp->current_component = $bp->default_component;
</span><span class="cx">
</span><span class="cx">         do_action( 'bp_core_setup_globals' );
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/comments.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/comments.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-themes/bp-default/comments.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">                         <?php do_action( 'bp_before_blog_comment_list' ) ?>
</span><span class="cx">
</span><span class="cx">                         <ol class="commentlist">
</span><del>-                                <?php wp_list_comments( array( 'callback' => 'bp_dtheme_comments' ) ); ?>
</del><ins>+                                <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments' ) ); ?>
</ins><span class="cx">                         </ol><!-- .comment-list -->
</span><span class="cx">
</span><span class="cx">                         <?php do_action( 'bp_after_blog_comment_list' ) ?>
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-themes/bp-default/functions.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
</span><span class="cx">
</span><del>-function bp_dtheme_comments( $comment, $args, $depth ) {
</del><ins>+function bp_dtheme_blog_comments( $comment, $args, $depth ) {
</ins><span class="cx"> $GLOBALS['comment'] = $comment;
</span><span class="cx">         $comment_type = get_comment_type();
</span><span class="cx">
</span><span class="lines">@@ -101,6 +101,15 @@
</span><span class="cx"> <?php
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function bp_dtheme_show_on_frontpage() {
+        $settings = get_option( 'bp_dtheme_options' );
+
+        if ( empty( $settings['show_on_frontpage'] ) || 'blog' == $settings['show_on_frontpage'] )
+                return 'blog';
+
+        return 'activity';
+}
+
</ins><span class="cx"> /* Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */
</span><span class="cx"> define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
</span><span class="cx"> define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri
</span><span class="lines">@@ -185,4 +194,22 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'init', 'bp_dtheme_remove_redundant' );
</span><span class="cx">
</span><ins>+function bp_dtheme_show_notice() { ?>
+        <div id="message" class="updated fade">
+                <p><?php printf( __( 'Theme activated! This theme contains <a href="%s">customization options</a> and <a href="%s">custom header image</a> support. <a href="%s">Sidebar widgets</a> are also supported.', 'buddypress' ), '', admin_url( 'themes.php?page=custom-header' ), '' ) ?></p>
+        </div>
+
+        <style type="text/css">#message2, #message0 { display: none; }</style>
+        <?php
+}
+
+/* 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() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
+        add_action( 'admin_notices', 'bp_dtheme_show_notice' );
+}
+
+/* Load the options page */
+if ( is_admin() )
+        require( TEMPLATEPATH . '/_inc/options.php' );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/header.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/header.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-themes/bp-default/header.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -40,29 +40,35 @@
</span><span class="cx">                                         <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a>
</span><span class="cx">                                 </li>
</span><span class="cx">
</span><del>-                                <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) || bp_is_blog_page() && !is_front_page() ) : ?> class="selected"<?php endif; ?>>
-                                        <a href="<?php echo site_url() ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a>
-                                </li>
</del><ins>+                                <?php if ( 'blog' == bp_dtheme_show_on_frontpage() ) : ?>
+                                        <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
+                                                <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
+                                        </li>
+                                <?php else : ?>
+                                        <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) || bp_is_blog_page() && !is_front_page() ) : ?> class="selected"<?php endif; ?>>
+                                                <a href="<?php echo site_url() ?>/<?php echo BP_HOME_BLOG_SLUG ?>/" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a>
+                                        </li>
+                                <?php endif; ?>
</ins><span class="cx">
</span><del>-                                <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
-                                        <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
</del><ins>+                                <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
+                                        <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
</ins><span class="cx">                                 </li>
</span><span class="cx">
</span><span class="cx">                                 <?php if ( function_exists( 'groups_install' ) ) : ?>
</span><span class="cx">                                         <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
</span><del>-                                                <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
</del><ins>+                                                <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
</ins><span class="cx">                                         </li>
</span><span class="cx">                                 <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                                 <?php if ( function_exists( 'groups_install' ) && ( function_exists( 'bp_forums_setup' ) && !(int) get_site_option( 'bp-disable-forum-directory' ) ) ) : ?>
</span><span class="cx">                                         <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
</span><del>-                                                <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
</del><ins>+                                                <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
</ins><span class="cx">                                         </li>
</span><span class="cx">                                 <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                                 <?php if ( function_exists( 'bp_blogs_install' ) && bp_core_is_multiblog_install() ) : ?>
</span><span class="cx">                                         <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
</span><del>-                                                <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a>
</del><ins>+                                                <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a>
</ins><span class="cx">                                         </li>
</span><span class="cx">                                 <?php endif; ?>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpthemesbpdefaulthomephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/home.php (2223 => 2224)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/home.php        2009-12-30 08:30:49 UTC (rev 2223)
+++ trunk/bp-themes/bp-default/home.php        2009-12-30 10:15:57 UTC (rev 2224)
</span><span class="lines">@@ -1,3 +1,10 @@
</span><span class="cx"> <?php
</span><del>-        locate_template( array( 'activity/index.php' ), true );
</del><ins>+        /***
+         * Should we show the blog on the front page, or the activity stream?
+         * This is set in wp-admin > Appearance > Theme Options
+         */
+        if ( 'blog' == bp_dtheme_show_on_frontpage() )
+                locate_template( array( 'index.php' ), true );
+        else
+                locate_template( array( 'activity/index.php' ), true );
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>