Index: /trunk/src/bp-activity/bp-activity-template.php
===================================================================
--- /trunk/src/bp-activity/bp-activity-template.php	(revision 9536)
+++ /trunk/src/bp-activity/bp-activity-template.php	(revision 9537)
@@ -240,5 +240,5 @@
 	 * }
 	 */
-	function __construct( $args ) {
+	public function __construct( $args ) {
 		$bp = buddypress();
 
@@ -367,16 +367,19 @@
 		// Fetch parent content for activity comments so we do not have to query in the loop
 		foreach ( (array) $this->activities as $activity ) {
-			if ( 'activity_comment' != $activity->type )
+			if ( 'activity_comment' != $activity->type ) {
 				continue;
+			}
 
 			$parent_ids[] = $activity->item_id;
 		}
 
-		if ( !empty( $parent_ids ) )
+		if ( !empty( $parent_ids ) ) {
 			$activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
+		}
 
 		if ( !empty( $activity_parents['activities'] ) ) {
-			foreach( $activity_parents['activities'] as $parent )
+			foreach( $activity_parents['activities'] as $parent ) {
 				$this->activity_parents[$parent->id] = $parent;
+			}
 
 			unset( $activity_parents );
@@ -405,6 +408,7 @@
 	 */
 	function has_activities() {
-		if ( $this->activity_count )
+		if ( $this->activity_count ) {
 			return true;
+		}
 
 		return false;
@@ -416,7 +420,7 @@
 	 * @return object The next activity item to iterate over.
 	 */
-	function next_activity() {
+	public function next_activity() {
 		$this->current_activity++;
-		$this->activity = $this->activities[$this->current_activity];
+		$this->activity = $this->activities[ $this->current_activity ];
 
 		return $this->activity;
@@ -426,5 +430,5 @@
 	 * Rewind the posts and reset post index.
 	 */
-	function rewind_activities() {
+	public function rewind_activities() {
 		$this->current_activity = -1;
 		if ( $this->activity_count > 0 ) {
@@ -445,8 +449,8 @@
 	 *              otherwise false.
 	 */
-	function user_activities() {
-		if ( $this->current_activity + 1 < $this->activity_count ) {
+	public function user_activities() {
+		if ( ( $this->current_activity + 1 ) < $this->activity_count ) {
 			return true;
-		} elseif ( $this->current_activity + 1 == $this->activity_count ) {
+		} elseif ( ( $this->current_activity + 1 ) == $this->activity_count ) {
 
 			/**
@@ -456,4 +460,5 @@
 			 */
 			do_action( 'activity_loop_end' );
+
 			// Do some cleaning up after the loop
 			$this->rewind_activities();
@@ -461,4 +466,5 @@
 
 		$this->in_the_loop = false;
+
 		return false;
 	}
@@ -473,13 +479,15 @@
 	 * @see bp_the_activity()
 	 */
-	function the_activity() {
+	public function the_activity() {
 
 		$this->in_the_loop = true;
 		$this->activity    = $this->next_activity();
 
-		if ( is_array( $this->activity ) )
+		if ( is_array( $this->activity ) ) {
 			$this->activity = (object) $this->activity;
-
-		if ( $this->current_activity == 0 ) { // loop has just started
+		}
+
+		// loop has just started
+		if ( $this->current_activity == 0 ) {
 
 			/**
@@ -1505,6 +1513,7 @@
 
 		// If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
-		if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
+		if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) {
 			$email = $current_activity_item->user_email;
+		}
 
 		/**
@@ -1745,10 +1754,7 @@
 		global $activities_template;
 
-		$defaults = array(
+		$args = wp_parse_args( $args, array(
 			'no_timestamp' => false,
-		);
-
-		$args = wp_parse_args( $args, $defaults );
-		extract( $args, EXTR_SKIP );
+		) );
 
 		$action = $activities_template->activity->action;
@@ -1763,6 +1769,7 @@
 		$action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) );
 
-		if ( ! empty( $action ) && ! $no_timestamp )
+		if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
 			$action = bp_insert_activity_meta( $action );
+		}
 
 		/**
@@ -1802,6 +1809,7 @@
 
 		// Backwards compatibility if action is not being used
-		if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
+		if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
 			$activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
+		}
 
 		/**
@@ -1827,6 +1835,7 @@
 	global $activities_template;
 
-	if ( !empty( $activities_template->activity->content ) )
+	if ( ! empty( $activities_template->activity->content ) ) {
 		return true;
+	}
 
 	return false;
@@ -2012,11 +2021,8 @@
 	 *
 	 * @global object $activities_template {@link BP_Activity_Template}
-	 * @uses wp_parse_args()
 	 * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
 	 *
-	 * @param array $args {
-	 *     Array of optional arguments.
-	 *     @deprecated bool $hide_user No longer used.
-	 * }
+	 * @param string $args Unused. Left over from an earlier implementation.
+	 *
 	 * @return mixed False on failure, otherwise the activity parent content
 	 */
@@ -2024,29 +2030,29 @@
 		global $activities_template;
 
-		$defaults = array(
-			'hide_user' => false
-		);
-
-		$r = wp_parse_args( $args, $defaults );
-		extract( $r, EXTR_SKIP );
+		// Bail if no activity on no item ID
+		if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
+			return false;
+		}
 
 		// Get the ID of the parent activity content
-		if ( !$parent_id = $activities_template->activity->item_id )
+		$parent_id = (int) $activities_template->activity->item_id;
+
+		// Bail if no parent content
+		if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
 			return false;
-
-		// Bail if no parent content
-		if ( empty( $activities_template->activity_parents[$parent_id] ) )
+		}
+
+		// Bail if no action
+		if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
 			return false;
-
-		// Bail if no action
-		if ( empty( $activities_template->activity_parents[$parent_id]->action ) )
-			return false;
+		}
 
 		// Content always includes action
-		$content = $activities_template->activity_parents[$parent_id]->action;
+		$content = $activities_template->activity_parents[ $parent_id ]->action;
 
 		// Maybe append activity content, if it exists
-		if ( ! empty( $activities_template->activity_parents[$parent_id]->content ) )
-			$content .= ' ' . $activities_template->activity_parents[$parent_id]->content;
+		if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
+			$content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
+		}
 
 		// Remove the time since content for backwards compatibility
@@ -2089,20 +2095,22 @@
 
 		// Bail if no activity on no item ID
-		if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) )
+		if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
 			return false;
+		}
 
 		// Get the ID of the parent activity content
-		if ( !$parent_id = $activities_template->activity->item_id )
+		$parent_id = (int) $activities_template->activity->item_id;
+
+		// Bail if no parent item
+		if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
 			return false;
-
-		// Bail if no parent item
-		if ( empty( $activities_template->activity_parents[$parent_id] ) )
+		}
+
+		// Bail if no parent user ID
+		if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
 			return false;
-
-		// Bail if no parent user ID
-		if ( empty( $activities_template->activity_parents[$parent_id]->user_id ) )
-			return false;
-
-		$retval = $activities_template->activity_parents[$parent_id]->user_id;
+		}
+
+		$retval = $activities_template->activity_parents[ $parent_id ]->user_id;
 
 		/**
@@ -2157,5 +2165,5 @@
  * @todo deprecate $args param
  *
- * @param string $args Unused. Appears to be left over from an earlier implementation.
+ * @param array $args See {@link bp_activity_get_comments} for description.
  */
 function bp_activity_comments( $args = '' ) {
@@ -2173,5 +2181,5 @@
 	 *    this function can probably be streamlined or removed.
 	 *
-	 * @param string $args Unused. Appears to be left over from an earlier implementation.
+	 * @param string $args Unused. Left over from an earlier implementation.
 	 *
 	 * @global object $activities_template {@link BP_Activity_Template}
@@ -2181,6 +2189,7 @@
 		global $activities_template;
 
-		if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children )
+		if ( empty( $activities_template->activity->children ) ) {
 			return false;
+		}
 
 		bp_activity_recurse_comments( $activities_template->activity );
@@ -2203,9 +2212,11 @@
 			global $activities_template;
 
-			if ( empty( $comment ) )
+			if ( empty( $comment ) ) {
 				return false;
-
-			if ( empty( $comment->children ) )
+			}
+
+			if ( empty( $comment->children ) ) {
 				return false;
+			}
 
 			/**
@@ -2216,6 +2227,7 @@
 			 * @param string $value Opening tag for the HTML markup to use.
 			 */
-			echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>');
+			echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
 			foreach ( (array) $comment->children as $comment_child ) {
+
 				// Put the comment into the global so it's available to filters
 				$activities_template->activity->current_comment = $comment_child;
@@ -2243,5 +2255,5 @@
 			 * @param string $value Closing tag for the HTML markup to use.
 			 */
-			echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>');
+			echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' );
 		}
 
@@ -2455,6 +2467,7 @@
 		global $activities_template;
 
-		if ( empty( $activities_template->activity->current_comment->date_recorded ) )
+		if ( empty( $activities_template->activity->current_comment->date_recorded ) ) {
 			return false;
+		}
 
 		$date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
@@ -2724,6 +2737,8 @@
 	function bp_get_activity_comment_form_nojs_display() {
 		global $activities_template;
-		if ( isset( $_GET['ac'] ) && $_GET['ac'] == $activities_template->activity->id . '/' )
+
+		if ( isset( $_GET['ac'] ) && ( $_GET['ac'] === ( $activities_template->activity->id . '/' ) ) ) {
 			return 'style="display: block"';
+		}
 
 		return false;
@@ -2998,9 +3013,11 @@
 		$class = ' activity-item';
 
-		if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) )
+		if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) {
 			$class .= ' mini';
-
-		if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
+		}
+
+		if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) {
 			$class .= ' has-comments';
+		}
 
 		/**
@@ -3149,12 +3166,15 @@
 	function bp_get_activity_latest_update( $user_id = 0 ) {
 
-		if ( empty( $user_id ) )
+		if ( empty( $user_id ) ) {
 			$user_id = bp_displayed_user_id();
-
-		if ( bp_is_user_inactive( $user_id ) )
+		}
+
+		if ( bp_is_user_inactive( $user_id ) ) {
 			return false;
-
-		if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
+		}
+
+		if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) {
 			return false;
+		}
 
 		/**
@@ -3220,10 +3240,7 @@
 	function bp_get_activity_filter_links( $args = false ) {
 
-		$defaults = array(
+		$r = wp_parse_args( $args, array(
 			'style' => 'list'
-		);
-
-		$r = wp_parse_args( $args, $defaults );
-		extract( $r, EXTR_SKIP );
+		) );
 
 		// Define local variable
@@ -3233,21 +3250,24 @@
 		$components = BP_Activity_Activity::get_recorded_components();
 
-		if ( empty( $components ) )
+		if ( empty( $components ) ) {
 			return false;
+		}
 
 		foreach ( (array) $components as $component ) {
 
 			// Skip the activity comment filter
-			if ( 'activity' == $component )
+			if ( 'activity' == $component ) {
 				continue;
-
-			if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] )
+			}
+
+			if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) {
 				$selected = ' class="selected"';
-			else
-				unset($selected);
+			} else {
+				$selected = '';
+			}
 
 			$component = esc_attr( $component );
 
-			switch ( $style ) {
+			switch ( $r['style'] ) {
 				case 'list':
 					$tag = 'li';
@@ -3285,6 +3305,7 @@
 		$link = remove_query_arg( 'afilter' , $link );
 
-		if ( isset( $_GET['afilter'] ) )
+		if ( isset( $_GET['afilter'] ) ) {
 			$component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
+		}
 
 		/**
