Commits

Doug Stewart committed b3e110f

Styling and doc fixes, initial code dump from bbPress default theme. Much more of that to come.

Comments (0)

Files changed (6)

 
 If you are interested in learning more about Mercurial, [HG Init](<http://hginit.com>) is an *excellent* starters' resource (and it's even pretty good for moderately-skilled Hg users, too!)
 
+### VERSION HISTORY ###
+
+* Version 1.1
+	* **Issues Fixed**
+		* BuddyPress Member/Group buttons not appearing
+		* Question mark next to @ names in individual Member screens now styling correctly
+* Version 1.0
+	* Initial release
+
 ### KNOWN ISSUES ###
 
 * Version 1.0
- * Specifying BuddyPress Activity as front page tosses 404 error
- * Header images max width at 960px.
- * "New Topic" & "Create Group" buttons styled incorrectly
- * Where's the "Add Friend" button?
- * Question mark JS anchor next to @ names doesn't place non-hidden text in the right place
+	* Specifying BuddyPress Activity as front page tosses 404 error
+	* Header images max width at 960px.
+	* "New Topic" & "Create Group" buttons styled incorrectly
+	* <del>Where's the "Add Friend" button?</del>
+	* <del>Question mark JS anchor next to @ names doesn't place non-hidden text in the right place</del>
 
 ### INSPIRATION ###
 
 require_once( LBLG_FUNCTIONS_DIR . 'supports.php' );
 
 // Only load the BuddyPress-related code if BP is active
-if( function_exists( 'bp_init' ))
+if( function_exists( 'bp_init' ) )
 	require_once( LBLG_FUNCTIONS_DIR . 'buddypress.php' );
-	
-require_once( LBLG_FUNCTIONS_DIR . 'bbpress.php' );
+
+if( function_exists( 'bbp_get_current_user_id' ) )	
+	require_once( LBLG_FUNCTIONS_DIR . 'bbpress.php' );
 ?>

includes/css/bp.css

     vertical-align: bottom;
     cursor: pointer;
 }
-    a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover,
-    ul.button-nav li a:hover, ul.button-nav li.current a,
-    div.generic-button a:hover {
-        border-color: #aaa;
-        color: #555;
-        outline: none;
-    }
 
-    /* Buttons that are disabled */
-    div.pending a, a.disabled {
-        border-color: #eee;
-        color: #bbb;
-        cursor: default;
-    }
-    div.pending a:hover, a.disabled:hover { border-color: #eee; color: #bbb; }
+a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover,
+ul.button-nav li a:hover, ul.button-nav li.current a,
+div.generic-button a:hover {
+    border-color: #aaa;
+    color: #555;
+    outline: none;
+}
 
-    div.accept, div.reject {
-        float: left;
-        margin-left: 10px;
-    }
+/* Buttons that are disabled */
+div.pending a, a.disabled {
+    border-color: #eee;
+    color: #bbb;
+    cursor: default;
+}
+div.pending a:hover, a.disabled:hover { border-color: #eee; color: #bbb; }
+
+div.accept, div.reject {
+    float: left;
+    margin-left: 10px;
+}
+
+div#item-header div.generic-button, div#item-header a.button {
+	float: left;
+	margin: 10px 10px 0 0;
+}
 
 body.directory #lb-content h3 {
 	color: #000;
 	    margin: -37px 0 0 0;
 }
 
+span.activity, div#message p {
+	display: inline-block;
+	font-size: 11px;
+	font-weight: normal;
+	background: #FFF9DB;
+	border-bottom: 1px solid #FFE8C4;
+	border-right: 1px solid #FFE8C4;
+	color: #ffa200;
+	padding: 1px 8px;
+	margin-top: 6px;
+	text-decoration: none;
+	-moz-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
 table.forum {
     width: 100%;
 }

includes/functions/bbpress.php

 <?php
+
+ /**
+ * @package bbPress
+ * @subpackage BBP_Twenty_Ten
+ * @since Twenty Ten 1.1
+ */
+
+if ( ! function_exists( 'bbp_twentyten_setup' ) ):
+/**
+ * Sets up theme support for bbPress
+ *
+ * If you're looking to add bbPress support into your own custom theme, you'll
+ * want to make sure to use: add_theme_support( 'bbpress' );
+ *
+ * @since bbPress (r2652)
+ */
+function bbp_twentyten_setup() {
+
+	// This theme comes bundled with bbPress template files
+	add_theme_support( 'bbpress' );
+}
+/** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
+add_action( 'after_setup_theme', 'bbp_twentyten_setup' );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_enqueue_styles' ) ) :
+/**
+ * Load the theme CSS
+ *
+ * @since bbPress (r2652)
+ *
+ * @uses is_admin() To check if it's the admin section
+ * @uses wp_enqueue_style() To enqueue the styles
+ */
+function bbp_twentyten_enqueue_styles () {
+	if ( is_admin() )
+		return false;
+
+	// Right to left
+	if ( is_rtl() ) {
+
+		// TwentyTen
+		wp_enqueue_style( 'twentyten',     get_template_directory_uri() . '/bbpress/style.css', '',          20100503, 'screen' );
+		wp_enqueue_style( 'twentyten-rtl', get_template_directory_uri() . '/bbpress/rtl.css',   'twentyten', 20100503, 'screen' );
+
+		// bbPress specific
+		wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/bbpress/css/bbpress-rtl.css', 'twentyten-rtl', 20100503, 'screen' );
+
+	// Left to right
+	} else {
+
+		// TwentyTen
+		wp_enqueue_style( 'twentyten', get_template_directory_uri() . '/bbpress/style.css', '', 20100503, 'screen' );
+
+		// bbPress specific
+		wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/bbpress/css/bbpress.css', 'twentyten', 20100503, 'screen' );
+	}
+}
+add_action( 'init', 'bbp_twentyten_enqueue_styles' );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_dim_favorite' ) ) :
+/**
+ * Add or remove a topic from a user's favorites
+ *
+ * @since bbPress (r2652)
+ *
+ * @uses bbp_get_current_user_id() To get the current user id
+ * @uses current_user_can() To check if the current user can edit the user
+ * @uses bbp_get_topic() To get the topic
+ * @uses check_ajax_referer() To verify the nonce & check the referer
+ * @uses bbp_is_user_favorite() To check if the topic is user's favorite
+ * @uses bbp_remove_user_favorite() To remove the topic from user's favorites
+ * @uses bbp_add_user_favorite() To add the topic from user's favorites
+ */
+function bbp_twentyten_dim_favorite () {
+	$user_id = bbp_get_current_user_id();
+	$id      = intval( $_POST['id'] );
+
+	if ( !current_user_can( 'edit_user', $user_id ) )
+		die( '-1' );
+
+	if ( !$topic = bbp_get_topic( $id ) )
+		die( '0' );
+
+	check_ajax_referer( "toggle-favorite_$topic->ID" );
+
+	if ( bbp_is_user_favorite( $user_id, $topic->ID ) ) {
+		if ( bbp_remove_user_favorite( $user_id, $topic->ID ) )
+			die( '1' );
+	} else {
+		if ( bbp_add_user_favorite( $user_id, $topic->ID ) )
+			die( '1' );
+	}
+
+	die( '0' );
+}
+add_action( 'wp_ajax_dim-favorite', 'bbp_twentyten_dim_favorite' );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_dim_subscription' ) ) :
+/**
+ * Subscribe/Unsubscribe a user from a topic
+ *
+ * @since bbPress (r2668)
+ *
+ * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
+ * @uses bbp_get_current_user_id() To get the current user id
+ * @uses current_user_can() To check if the current user can edit the user
+ * @uses bbp_get_topic() To get the topic
+ * @uses check_ajax_referer() To verify the nonce & check the referer
+ * @uses bbp_is_user_subscribed() To check if the topic is in user's
+ *                                 subscriptions
+ * @uses bbp_remove_user_subscriptions() To remove the topic from user's
+ *                                        subscriptions
+ * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
+ */
+function bbp_twentyten_dim_subscription () {
+	if ( !bbp_is_subscriptions_active() )
+		return;
+
+	$user_id = bbp_get_current_user_id();
+	$id      = intval( $_POST['id'] );
+
+	if ( !current_user_can( 'edit_user', $user_id ) )
+		die( '-1' );
+
+	if ( !$topic = bbp_get_topic( $id ) )
+		die( '0' );
+
+	check_ajax_referer( "toggle-subscription_$topic->ID" );
+
+	if ( bbp_is_user_subscribed( $user_id, $topic->ID ) ) {
+		if ( bbp_remove_user_subscription( $user_id, $topic->ID ) )
+			die( '1' );
+	} else {
+		if ( bbp_add_user_subscription( $user_id, $topic->ID ) )
+			die( '1' );
+	}
+
+	die( '0' );
+}
+add_action( 'wp_ajax_dim-subscription', 'bbp_twentyten_dim_subscription' );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_enqueue_scripts' ) ) :
+/**
+ * Enqueue the required Javascript files
+ *
+ * @since bbPress (r2652)
+ *
+ * @uses bbp_is_topic() To check if it's the topic page
+ * @uses get_stylesheet_directory_uri() To get the stylesheet directory uri
+ * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
+ * @uses wp_enqueue_script() To enqueue the scripts
+ */
+function bbp_twentyten_enqueue_scripts () {
+	if ( bbp_is_topic() )
+		wp_enqueue_script( 'bbp_topic', get_stylesheet_directory_uri() . '/bbpress/js/topic.js', array( 'wp-lists' ), '20101202' );
+
+	if ( bbp_is_user_profile_edit() )
+		wp_enqueue_script( 'user-profile' );
+}
+add_action( 'wp_enqueue_scripts', 'bbp_twentyten_enqueue_scripts' );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_scripts' ) ) :
+/**
+ * Put some scripts in the header, like AJAX url for wp-lists
+ *
+ * @since bbPress (r2652)
+ *
+ * @uses bbp_is_topic() To check if it's the topic page
+ * @uses admin_url() To get the admin url
+ * @uses bbp_is_user_profile_edit() To check if it's the profile edit page
+ */
+function bbp_twentyten_scripts () {
+	if ( bbp_is_topic() ) : ?>
+
+	<script type='text/javascript'>
+		/* <![CDATA[ */
+		var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
+		/* ]]> */
+	</script>
+
+	<?php elseif ( bbp_is_user_profile_edit() ) : ?>
+
+	<script type="text/javascript" charset="utf-8">
+		if ( window.location.hash == '#password' ) {
+			document.getElementById('pass1').focus();
+		}
+	</script>
+
+	<?php
+	endif;
+}
+add_filter( 'wp_head', 'bbp_twentyten_scripts', -1 );
+endif;
+
+if ( !function_exists( 'bbp_twentyten_topic_script_localization' ) ) :
+/**
+ * Load localizations for topic script.
+ *
+ * These localizations require information that may not be loaded even by init.
+ *
+ * @since bbPress (r2652)
+ *
+ * @uses bbp_is_topic() To check if it's the topic page
+ * @uses bbp_get_current_user_id() To get the current user id
+ * @uses bbp_get_topic_id() To get the topic id
+ * @uses bbp_get_favorites_permalink() To get the favorites permalink
+ * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
+ * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
+ * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
+ * @uses bbp_get_topic_permalink() To get the topic permalink
+ * @uses wp_localize_script() To localize the script
+ */
+function bbp_twentyten_topic_script_localization () {
+	if ( !bbp_is_topic() )
+		return;
+
+	$user_id = bbp_get_current_user_id();
+
+	$localizations = array(
+		'currentUserId' => $user_id,
+		'topicId'       => bbp_get_topic_id(),
+		'favoritesLink' => bbp_get_favorites_permalink( $user_id ),
+		'isFav'         => (int) bbp_is_user_favorite( $user_id ),
+		'favLinkYes'    => __( 'favorites',                                         'bbpress' ),
+		'favLinkNo'     => __( '?',                                                 'bbpress' ),
+		'favYes'        => __( 'This topic is one of your %favLinkYes% [%favDel%]', 'bbpress' ),
+		'favNo'         => __( '%favAdd% (%favLinkNo%)',                            'bbpress' ),
+		'favDel'        => __( '&times;',                                           'bbpress' ),
+		'favAdd'        => __( 'Add this topic to your favorites',                  'bbpress' )
+	);
+
+	if ( bbp_is_subscriptions_active() ) {
+		$localizations['subsActive']   = 1;
+		$localizations['isSubscribed'] = (int) bbp_is_user_subscribed( $user_id );
+		$localizations['subsSub']      = __( 'Subscribe', 'bbpress' );
+		$localizations['subsUns']      = __( 'Unsubscribe', 'bbpress' );
+		$localizations['subsLink']     = bbp_get_topic_permalink();
+	} else {
+		$localizations['subsActive'] = 0;
+	}
+
+	wp_localize_script( 'bbp_topic', 'bbpTopicJS', $localizations );
+}
+add_filter( 'wp_enqueue_scripts', 'bbp_twentyten_topic_script_localization' );
+endif;
+
+?>

includes/functions/buddypress.php

  */
 function lblg_bp_add_buttons() {
 	// Member Buttons
-	if ( bp_is_active( 'friends' ) )
+	if ( bp_is_active( 'friends' ) ) 
 		add_action( 'bp_member_header_actions',    'bp_add_friend_button' );
 	
 	if ( bp_is_active( 'activity' ) )
 	if ( bp_is_active( 'blogs' ) )
 		add_action( 'bp_directory_blogs_actions',  'bp_blogs_visit_blog_button' );
 }
-add_action( 'bp_init', 'lblg_bp_add_buttons' );
+add_action( 'widgets_init', 'lblg_bp_add_buttons' );
 /*
 Theme Name: Elbee Elgee
 Theme URI: http://literalbarrage.org/blog/code/lblg
-Description: An extremely flexible 3 column theme.
+Description: An extremely flexible 1, 2, or 3 column theme with over 30 possible layouts and support for widgetized sidebars, custom headers, custom backgrounds, custom navigation menus, BuddyPress and bbPress.
 Author: Doug Stewart
 Author URI: http://literalbarrage.org/blog/
 License: GPL v2