<!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][3742] trunk: Adjust internal action load orders to stop 'doing it wrong' by moving appropriate actions off plugins_loaded and into init.</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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd>3742</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-01-19 08:31:10 +0000 (Wed, 19 Jan 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Adjust internal action load orders to stop 'doing it wrong' by moving appropriate actions off plugins_loaded and into init. Fixes #2609 but will need testing; it may have adverse effects on external plugins. Adds missing function_exists checks to bp-default functions.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpcorebpcoreadminbarphp">trunk/bp-core/bp-core-adminbar.php</a></li>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpcorebpcorecatchuriphp">trunk/bp-core/bp-core-catchuri.php</a></li>
<li><a href="#trunkbpcorebpcorecssjsphp">trunk/bp-core/bp-core-cssjs.php</a></li>
<li><a href="#trunkbpcorebpcoredeprecatedphp">trunk/bp-core/bp-core-deprecated.php</a></li>
<li><a href="#trunkbpcorebpcoresignupphp">trunk/bp-core/bp-core-signup.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
<li><a href="#trunkbpfriendsphp">trunk/bp-friends.php</a></li>
<li><a href="#trunkbploaderphp">trunk/bp-loader.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-activity.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -1266,7 +1266,7 @@
</span><span class="cx"> function bp_register_activity_actions() {
</span><span class="cx">         do_action( 'bp_register_activity_actions' );
</span><span class="cx"> }
</span><del>-add_action( 'bp_loaded', 'bp_register_activity_actions', 8 );
</del><ins>+add_action( 'bp_init', 'bp_register_activity_actions', 8 );
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkbpcorebpcoreadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-adminbar.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-adminbar.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-adminbar.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -308,6 +308,6 @@
</span><span class="cx">                 add_action( 'admin_footer', 'bp_core_admin_bar'    );        
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-add_action( 'bp_loaded', 'bp_core_load_admin_bar' );
</del><ins>+add_action( 'bp_init', 'bp_core_load_admin_bar' );
</ins><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-avatars.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">         if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
</span><span class="cx">                 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-core/images/mystery-man-50.jpg' );
</span><span class="cx"> }
</span><del>-add_action( 'bp_loaded', 'bp_core_set_avatar_constants', 8 );
</del><ins>+add_action( 'bp_init', 'bp_core_set_avatar_constants', 8 );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * bp_core_fetch_avatar()
</span></span></pre></div>
<a id="trunkbpcorebpcorecatchuriphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-catchuri.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-catchuri.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-catchuri.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -212,7 +212,7 @@
</span><span class="cx">         // Reset the keys by merging with an empty array
</span><span class="cx">         $action_variables = array_merge( array(), $action_variables );
</span><span class="cx"> }
</span><del>-add_action( 'bp_loaded', 'bp_core_set_uri_globals', 4 );
</del><ins>+add_action( 'bp_init', 'bp_core_set_uri_globals', 4 );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * bp_core_load_template()
</span></span></pre></div>
<a id="trunkbpcorebpcorecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cssjs.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cssjs.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-cssjs.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">                         wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/css/adminbar.css' ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-add_action( 'init', 'bp_core_add_admin_bar_css' );
</del><ins>+add_action( 'bp_init', 'bp_core_add_admin_bar_css' );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * bp_core_admin_menu_icon_css()
</span></span></pre></div>
<a id="trunkbpcorebpcoredeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-deprecated.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-deprecated.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-deprecated.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">         // If there was no match, add a page for this root component
</span><span class="cx">         if ( empty( $match ) ) {
</span><span class="cx">                 $bp-&gt;add_root[] = $slug;
</span><del>-                add_action( 'init', 'bp_core_create_root_component_page' );
</del><ins>+                add_action( 'bp_init', 'bp_core_create_root_component_page' );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorebpcoresignupphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-signup.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-signup.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core/bp-core-signup.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -622,6 +622,6 @@
</span><span class="cx"> if ( is_multisite() )
</span><span class="cx">         add_action( 'wp', 'bp_core_wpsignup_redirect' );
</span><span class="cx"> else
</span><del>-        add_action( 'init', 'bp_core_wpsignup_redirect' );
</del><ins>+        add_action( 'bp_init', 'bp_core_wpsignup_redirect' );
</ins><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-core.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -252,54 +252,40 @@
</span><span class="cx">                 update_option( 'bp-pages', $page_ids );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> function bp_core_get_page_names() {
</span><del>-        global $wpdb;
</del><ins>+        global $wpdb, $bp;
</ins><span class="cx"> 
</span><del>-        $page_ids = bp_core_get_page_meta();
-
</del><ins>+        // Set pages as standard class
</ins><span class="cx">         $pages = new stdClass;
</span><span class="cx"> 
</span><del>-        // When upgrading to BP 1.3+ from a version of BP that does not use WP pages, $bp-&gt;pages
-        // must be populated with dummy info to avoid crashing the site while the db is upgraded
-        if ( empty( $page_ids ) ) {
-                $dummy_components = array(
-                        'members',
-                        'groups',
-                        'activity',
-                        'forums',
-                        'activate',
-                        'register',
-                        'blogs'
-                );
-                
-                foreach ( $dummy_components as $dc ) {
-                        $pages-&gt;{$dc}-&gt;name         = $dc;
-                        $pages-&gt;{$dc}-&gt;slug         = $dc;
-                        $pages-&gt;{$dc}-&gt;id         = $dc;
</del><ins>+        // When upgrading to BP 1.3+ from a version of BP that does not use WP
+        // pages, $bp-&gt;pages must be populated with dummy info to avoid crashing the
+        // site while the db is upgraded.
+        if ( !$page_ids = bp_core_get_page_meta() ) {                
+                foreach ( $bp-&gt;active_components as $component ) {
+                        $pages-&gt;{$component-&gt;id}-&gt;name = $component-&gt;id;
+                        $pages-&gt;{$component-&gt;id}-&gt;slug = $component-&gt;id;
+                        $pages-&gt;{$component-&gt;id}-&gt;id   = $component-&gt;id;
</ins><span class="cx">                 }
</span><span class="cx">                 
</span><span class="cx">                 return $pages;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $posts_table_name = is_multisite() &amp;&amp; !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb-&gt;get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb-&gt;posts;
</span><ins>+        $page_ids_sql     = implode( ',', (array)$page_ids );
+        $page_names       = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) &quot; ) );
</ins><span class="cx"> 
</span><del>-        $page_ids_sql = implode( ',', (array)$page_ids );
-
-        $page_names = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) &quot; ) );
-
</del><span class="cx">         foreach ( (array)$page_ids as $key =&gt; $page_id ) {
</span><span class="cx">                 foreach ( (array)$page_names as $page_name ) {
</span><span class="cx">                         if ( $page_name-&gt;ID == $page_id ) {
</span><span class="cx">                                 $pages-&gt;{$key}-&gt;name = $page_name-&gt;post_name;
</span><del>-                                $pages-&gt;{$key}-&gt;id = $page_name-&gt;ID;
</del><ins>+                                $pages-&gt;{$key}-&gt;id   = $page_name-&gt;ID;
+                                $slug[]              = $page_name-&gt;post_name;
</ins><span class="cx"> 
</span><del>-                                $slug[] = $page_name-&gt;post_name;
-
-                                /* Get the slug */
</del><ins>+                                // Get the slug
</ins><span class="cx">                                 while ( $page_name-&gt;post_parent != 0 ) {
</span><del>-                                        $parent = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d&quot;, $page_name-&gt;post_parent ) );
-                                        $slug[] = $parent[0]-&gt;post_name;
</del><ins>+                                        $parent                 = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d&quot;, $page_name-&gt;post_parent ) );
+                                        $slug[]                 = $parent[0]-&gt;post_name;
</ins><span class="cx">                                         $page_name-&gt;post_parent = $parent[0]-&gt;post_parent;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -376,12 +362,12 @@
</span><span class="cx"> 
</span><span class="cx">         // Add the administration tab under the &quot;Site Admin&quot; tab for site administrators
</span><span class="cx">         $hook = bp_core_add_admin_menu_page( array(
</span><del>-                'menu_title'   =&gt; __( 'BuddyPress', 'buddypress' ),
-                'page_title'   =&gt; __( 'BuddyPress', 'buddypress' ),
-                'capability'   =&gt; 'manage_options',
-                'file'         =&gt; 'bp-general-settings',
-                'function'     =&gt; 'bp_core_admin_dashboard',
-                'position'     =&gt; 2
</del><ins>+                'menu_title' =&gt; __( 'BuddyPress', 'buddypress' ),
+                'page_title' =&gt; __( 'BuddyPress', 'buddypress' ),
+                'capability' =&gt; 'manage_options',
+                'file'       =&gt; 'bp-general-settings',
+                'function'   =&gt; 'bp_core_admin_dashboard',
+                'position'   =&gt; 2
</ins><span class="cx">         ) );
</span><span class="cx"> 
</span><span class="cx">         add_submenu_page( 'bp-general-settings', __( 'BuddyPress Dashboard', 'buddypress' ), __( 'Dashboard', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_dashboard' );
</span><span class="lines">@@ -410,11 +396,11 @@
</span><span class="cx">          * built in WordPress profile information
</span><span class="cx">          */
</span><span class="cx">         if ( !bp_is_active( 'xprofile' ) ) {
</span><del>-                /* Fallback values if xprofile is disabled */
</del><ins>+                // Fallback values if xprofile is disabled
</ins><span class="cx">                 $bp-&gt;core-&gt;profile-&gt;slug = 'profile';
</span><span class="cx">                 $bp-&gt;active_components[$bp-&gt;core-&gt;profile-&gt;slug] = $bp-&gt;core-&gt;profile-&gt;slug;
</span><span class="cx"> 
</span><del>-                /* Add 'Profile' to the main navigation */
</del><ins>+                // Add 'Profile' to the main navigation
</ins><span class="cx">                 bp_core_new_nav_item( array(
</span><span class="cx">                         'name' =&gt; __('Profile', 'buddypress'),
</span><span class="cx">                         'slug' =&gt; $bp-&gt;core-&gt;profile-&gt;slug,
</span><span class="lines">@@ -425,7 +411,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $profile_link = $bp-&gt;loggedin_user-&gt;domain . '/profile/';
</span><span class="cx"> 
</span><del>-                /* Add the subnav items to the profile */
</del><ins>+                // Add the subnav items to the profile
</ins><span class="cx">                 bp_core_new_subnav_item( array(
</span><span class="cx">                         'name' =&gt; __( 'Public', 'buddypress' ),
</span><span class="cx">                         'slug' =&gt; 'public',
</span><span class="lines">@@ -1443,7 +1429,7 @@
</span><span class="cx">                 $name2 = $chunks[$i + 1][1];
</span><span class="cx"> 
</span><span class="cx">                 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
</span><del>-                        /* Add to output var */
</del><ins>+                        // Add to output var
</ins><span class="cx">                         $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1696,7 +1682,7 @@
</span><span class="cx"> 
</span><span class="cx">         bp_core_redirect( apply_filters( 'bp_core_search_site', site_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
</span><span class="cx"> }
</span><del>-add_action( 'init', 'bp_core_action_search_site', 5 );
</del><ins>+add_action( 'bp_init', 'bp_core_action_search_site', 7 );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Localization safe ucfirst() support.
</span><span class="lines">@@ -1864,14 +1850,14 @@
</span><span class="cx">         else
</span><span class="cx">                 return false;
</span><span class="cx"> }
</span><del>-add_action ( 'bp_loaded', 'bp_core_load_buddypress_textdomain', 2 );
</del><ins>+add_action ( 'bp_init', 'bp_core_load_buddypress_textdomain', 2 );
</ins><span class="cx"> 
</span><span class="cx"> function bp_core_add_ajax_hook() {
</span><span class="cx">         // Theme only, we already have the wp_ajax_ hook firing in wp-admin
</span><span class="cx">         if ( !defined( 'WP_ADMIN' ) &amp;&amp; isset( $_REQUEST['action'] ) )
</span><span class="cx">                 do_action( 'wp_ajax_' . $_REQUEST['action'] );
</span><span class="cx"> }
</span><del>-add_action( 'init', 'bp_core_add_ajax_hook' );
</del><ins>+add_action( 'bp_init', 'bp_core_add_ajax_hook' );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Add an extra update message to the update plugin notification.
</span><span class="lines">@@ -1956,62 +1942,63 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/********************************************************************************
- * Custom Actions
</del><ins>+/**
+ * BuddyPress uses site options to store configuration settings. Many of these settings are needed
+ * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
+ * them all in one go.
</ins><span class="cx">  *
</span><del>- * Functions to set up custom BuddyPress actions that all other components can
- * hook in to.
</del><ins>+ * @package BuddyPress Core
</ins><span class="cx">  */
</span><ins>+function bp_core_get_site_options() {
+        global $bp, $wpdb;
</ins><span class="cx"> 
</span><del>-/**
- * Allow plugins to include their files ahead of core filters
- */
-function bp_include() {
-        do_action( 'bp_include' );
-}
-add_action( 'bp_loaded', 'bp_include', 2 );
</del><ins>+        // These options come from the options table in WP single, and sitemeta in MS
+        $site_options = apply_filters( 'bp_core_site_options', array(
+                'bp-deactivated-components',
+                'bp-blogs-first-install',
+                'bp-disable-blog-forum-comments',
+                'bp-xprofile-base-group-name',
+                'bp-xprofile-fullname-field-name',
+                'bp-disable-profile-sync',
+                'bp-disable-avatar-uploads',
+                'bp-disable-account-deletion',
+                'bp-disable-forum-directory',
+                'bp-disable-blogforum-comments',
+                'bb-config-location',
+                'hide-loggedout-adminbar',
</ins><span class="cx"> 
</span><del>-/**
- * Allow core components and dependent plugins to set root components
- */
-function bp_setup_root_components() {
-        do_action( 'bp_setup_root_components' );
-}
-add_action( 'bp_loaded', 'bp_setup_root_components', 2 );
</del><ins>+                // Useful WordPress settings used often
+                'tags_blog_id',
+                'registration',
+                'fileupload_maxk'
+        ) );
</ins><span class="cx"> 
</span><del>-/**
- * Allow core components and dependent plugins to set globals
- */
-function bp_setup_globals() {
-        do_action( 'bp_setup_globals' );
-}
-add_action( 'bp_loaded', 'bp_setup_globals', 6 );
</del><ins>+        // These options always come from the options table of BP_ROOT_BLOG
+        $root_blog_options = apply_filters( 'bp_core_root_blog_options', array(
+                'avatar_default'
+        ) );
</ins><span class="cx"> 
</span><del>-/**
- * Allow core components and dependent plugins to set their nav
- */
-function bp_setup_nav() {
-        do_action( 'bp_setup_nav' );
-}
-add_action( 'bp_loaded', 'bp_setup_nav', 8 );
</del><ins>+        $meta_keys = &quot;'&quot; . implode( &quot;','&quot;, (array)$site_options ) .&quot;'&quot;;
</ins><span class="cx"> 
</span><del>-/**
- * Allow core components and dependent plugins to register widgets
- */
-function bp_setup_widgets() {
-        do_action( 'bp_register_widgets' );
-}
-add_action( 'bp_loaded', 'bp_setup_widgets', 8 );
</del><ins>+        if ( is_multisite() )
+                $site_meta = $wpdb-&gt;get_results( &quot;SELECT meta_key AS name, meta_value AS value FROM {$wpdb-&gt;sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb-&gt;siteid}&quot; );
+        else
+                $site_meta = $wpdb-&gt;get_results( &quot;SELECT option_name AS name, option_value AS value FROM {$wpdb-&gt;options} WHERE option_name IN ({$meta_keys})&quot; );
</ins><span class="cx"> 
</span><del>-/**
- * Allow components to initialize themselves cleanly
- */
-function bp_init() {
-        do_action( 'bp_init' );
</del><ins>+        $root_blog_meta_keys  = &quot;'&quot; . implode( &quot;','&quot;, (array)$root_blog_options ) .&quot;'&quot;;
+        $root_blog_meta_table = $wpdb-&gt;get_blog_prefix( BP_ROOT_BLOG ) . 'options';
+        $root_blog_meta       = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})&quot; ) );
+
+        $site_options = array();
+        foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
+                if ( !empty( $meta ) ) {
+                        foreach( (array)$meta as $meta_item )
+                                $site_options[$meta_item-&gt;name] = $meta_item-&gt;value;
+                }
+        }
+        return apply_filters( 'bp_core_get_site_options', $site_options );
</ins><span class="cx"> }
</span><del>-add_action( 'bp_loaded', 'bp_init' );
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> /********************************************************************************
</span><span class="cx">  * Caching
</span><span class="cx">  *
</span><span class="lines">@@ -2030,7 +2017,7 @@
</span><span class="cx">         if ( function_exists( 'wp_cache_add_global_groups' ) )
</span><span class="cx">                 wp_cache_add_global_groups( array( 'bp' ) );
</span><span class="cx"> }
</span><del>-add_action( 'init', 'bp_core_add_global_group' );
</del><ins>+add_action( 'bp_loaded', 'bp_core_add_global_group' );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Clears all cached objects for a user, or a user is part of.
</span></span></pre></div>
<a id="trunkbpfriendsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-friends.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -200,7 +200,7 @@
</span><span class="cx"> 
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><del>-add_action( 'init', 'friends_action_add_friend' );
</del><ins>+add_action( 'bp_init', 'friends_action_add_friend' );
</ins><span class="cx"> 
</span><span class="cx"> function friends_action_remove_friend() {
</span><span class="cx">         global $bp;
</span><span class="lines">@@ -239,7 +239,7 @@
</span><span class="cx"> 
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><del>-add_action( 'init', 'friends_action_remove_friend' );
</del><ins>+add_action( 'bp_init', 'friends_action_remove_friend' );
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> /********************************************************************************
</span></span></pre></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-loader.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -71,76 +71,70 @@
</span><span class="cx">                  define( 'BP_IS_UPGRADE', true ); 
</span><span class="cx">                  require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 
</span><span class="cx">          } 
</span><ins>+}
</ins><span class="cx"> 
</span><del>-        add_action( 'plugins_loaded', 'bp_loaded', 20 );
</del><ins>+/********************************************************************************
+ * Custom Actions
+ *
+ * Functions to set up custom BuddyPress actions that all other components can
+ * hook in to.
+ */
+
+/**
+ * Allow plugins to include their files ahead of core filters
+ */
+function bp_include() {
+        do_action( 'bp_include' );
</ins><span class="cx"> }
</span><ins>+add_action( 'bp_loaded', 'bp_include', 2 );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Allow dependent plugins and core actions to attach themselves in a safe way.
- *
- * See bp-core.php for the following core actions:
- *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
</del><ins>+ * Allow core components and dependent plugins to set root components
</ins><span class="cx">  */
</span><del>-function bp_loaded() {
-        do_action( 'bp_loaded' );
</del><ins>+function bp_setup_root_components() {
+        do_action( 'bp_setup_root_components' );
</ins><span class="cx"> }
</span><ins>+add_action( 'bp_init', 'bp_setup_root_components', 2 );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * BuddyPress uses site options to store configuration settings. Many of these settings are needed
- * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
- * them all in one go.
- *
- * @package BuddyPress Core
</del><ins>+ * Allow core components and dependent plugins to set globals
</ins><span class="cx">  */
</span><del>-function bp_core_get_site_options() {
-        global $bp, $wpdb;
</del><ins>+function bp_setup_globals() {
+        do_action( 'bp_setup_globals' );
+}
+add_action( 'bp_init', 'bp_setup_globals', 6 );
</ins><span class="cx"> 
</span><del>-        // These options come from the options table in WP single, and sitemeta in MS
-        $site_options = apply_filters( 'bp_core_site_options', array(
-                'bp-deactivated-components',
-                'bp-blogs-first-install',
-                'bp-disable-blog-forum-comments',
-                'bp-xprofile-base-group-name',
-                'bp-xprofile-fullname-field-name',
-                'bp-disable-profile-sync',
-                'bp-disable-avatar-uploads',
-                'bp-disable-account-deletion',
-                'bp-disable-forum-directory',
-                'bp-disable-blogforum-comments',
-                'bb-config-location',
-                'hide-loggedout-adminbar',
</del><ins>+/**
+ * Allow core components and dependent plugins to set their nav
+ */
+function bp_setup_nav() {
+        do_action( 'bp_setup_nav' );
+}
+add_action( 'bp_init', 'bp_setup_nav', 8 );
</ins><span class="cx"> 
</span><del>-                // Useful WordPress settings used often
-                'tags_blog_id',
-                'registration',
-                'fileupload_maxk'
-        ) );
</del><ins>+/**
+ * Allow core components and dependent plugins to register widgets
+ */
+function bp_setup_widgets() {
+        do_action( 'bp_register_widgets' );
+}
+add_action( 'bp_init', 'bp_setup_widgets', 8 );
</ins><span class="cx"> 
</span><del>-        // These options always come from the options table of BP_ROOT_BLOG
-        $root_blog_options = apply_filters( 'bp_core_root_blog_options', array(
-                'avatar_default'
-        ) );
</del><ins>+/**
+ * Allow components to initialize themselves cleanly
+ */
+function bp_init() {
+        do_action( 'bp_init' );
+}
+add_action( 'init', 'bp_init' );
</ins><span class="cx"> 
</span><del>-        $meta_keys = &quot;'&quot; . implode( &quot;','&quot;, (array)$site_options ) .&quot;'&quot;;
-
-        if ( is_multisite() )
-                $site_meta = $wpdb-&gt;get_results( &quot;SELECT meta_key AS name, meta_value AS value FROM {$wpdb-&gt;sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb-&gt;siteid}&quot; );
-        else
-                $site_meta = $wpdb-&gt;get_results( &quot;SELECT option_name AS name, option_value AS value FROM {$wpdb-&gt;options} WHERE option_name IN ({$meta_keys})&quot; );
-
-        $root_blog_meta_keys  = &quot;'&quot; . implode( &quot;','&quot;, (array)$root_blog_options ) .&quot;'&quot;;
-        $root_blog_meta_table = $wpdb-&gt;get_blog_prefix( BP_ROOT_BLOG ) . 'options';
-        $root_blog_meta       = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})&quot; ) );
-
-        $site_options = array();
-        foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
-                if ( !empty( $meta ) ) {
-                        foreach( (array)$meta as $meta_item )
-                                $site_options[$meta_item-&gt;name] = $meta_item-&gt;value;
-                }
-        }
-        return apply_filters( 'bp_core_get_site_options', $site_options );
</del><ins>+/**
+ * Attached to plugins_loaded
+ */
+function bp_loaded() {
+        do_action( 'bp_loaded' );
</ins><span class="cx"> }
</span><ins>+add_action( 'plugins_loaded', 'bp_loaded', 10 );
</ins><span class="cx"> 
</span><span class="cx"> /** 
</span><span class="cx">  * Defines BP's activation routine. 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (3741 => 3742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2011-01-19 08:30:32 UTC (rev 3741)
+++ trunk/bp-themes/bp-default/functions.php        2011-01-19 08:31:10 UTC (rev 3742)
</span><span class="lines">@@ -116,8 +116,9 @@
</span><span class="cx"> add_action( 'after_setup_theme', 'bp_dtheme_setup' );
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_enqueue_scripts' ) ) :
</ins><span class="cx"> /**
</span><del>- * Enqueue theme javascript safely after the 'init' action, per WordPress Codex.
</del><ins>+ * Enqueue theme javascript safely
</ins><span class="cx">  *
</span><span class="cx">  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
</span><span class="cx">  * @see http://codex.wordpress.org/Function_Reference/wp_enqueue_script
</span><span class="lines">@@ -145,6 +146,7 @@
</span><span class="cx">         wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_scripts' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><span class="cx"> if ( !function_exists( 'bp_dtheme_admin_header_style' ) ) :
</span><span class="cx"> /**
</span><span class="lines">@@ -288,6 +290,7 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_widgets_init' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Register widgetised areas, including one sidebar and four widget-ready columns in the footer.
</span><span class="cx">  *
</span><span class="lines">@@ -354,6 +357,7 @@
</span><span class="cx">         ) );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'widgets_init', 'bp_dtheme_widgets_init' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><span class="cx"> if ( !function_exists( 'bp_dtheme_blog_comments' ) ) :
</span><span class="cx"> /**
</span><span class="lines">@@ -424,6 +428,7 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_page_on_front' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Return the ID of a page set as the home page.
</span><span class="cx">  *
</span><span class="lines">@@ -436,7 +441,9 @@
</span><span class="cx"> 
</span><span class="cx">         return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) );
</span><span class="cx"> }
</span><ins>+endif;
</ins><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_activity_secondary_avatars' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Add secondary avatar image to this activity stream's record, if supported.
</span><span class="cx">  *
</span><span class="lines">@@ -462,7 +469,9 @@
</span><span class="cx">         return $action;
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
</span><ins>+endif;
</ins><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_show_notice' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html)
</span><span class="cx">  *
</span><span class="lines">@@ -478,6 +487,7 @@
</span><span class="cx"> }
</span><span class="cx"> if ( is_admin() &amp;&amp; isset($_GET['activated'] ) &amp;&amp; $pagenow == &quot;themes.php&quot; )
</span><span class="cx">         add_action( 'admin_notices', 'bp_dtheme_show_notice' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><span class="cx"> if ( !function_exists( 'bp_dtheme_main_nav' ) ) :
</span><span class="cx"> /**
</span><span class="lines">@@ -515,6 +525,7 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_page_menu_args' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Get our wp_nav_menu() fallback, bp_dtheme_main_nav(), to show a home link.
</span><span class="cx">  *
</span><span class="lines">@@ -527,7 +538,9 @@
</span><span class="cx">         return $args;
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'wp_page_menu_args', 'bp_dtheme_page_menu_args' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_comment_form' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Applies BuddyPress customisations to the post comment form.
</span><span class="cx">  *
</span><span class="lines">@@ -563,7 +576,9 @@
</span><span class="cx">         return apply_filters( 'bp_dtheme_comment_form', array_merge( $default_labels, $new_labels ) );
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'comment_form_defaults', 'bp_dtheme_comment_form', 10 );
</span><ins>+endif;
</ins><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_before_comment_form' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Adds the user's avatar before the comment form box.
</span><span class="cx">  *
</span><span class="lines">@@ -591,7 +606,9 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><span class="cx"> add_action( 'comment_form_top', 'bp_dtheme_before_comment_form' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><ins>+if ( !function_exists( 'bp_dtheme_after_comment_form' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * Closes tags opened in bp_dtheme_before_comment_form().
</span><span class="cx">  *
</span><span class="lines">@@ -601,14 +618,18 @@
</span><span class="cx">  */
</span><span class="cx"> function bp_dtheme_after_comment_form() {
</span><span class="cx"> ?&gt;
</span><ins>+
</ins><span class="cx">         &lt;/div&gt;&lt;!-- .comment-content standard-form --&gt;
</span><ins>+
</ins><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><span class="cx"> add_action( 'comment_form', 'bp_dtheme_after_comment_form' );
</span><ins>+endif;
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> // Everything beyond this point is deprecated as of BuddyPress 1.3. This will be removed in a future version.
</span><span class="cx"> 
</span><ins>+if ( BP_VERSION &lt; 1.3 ) :
+
</ins><span class="cx"> /**
</span><span class="cx">  * In BuddyPress 1.2.x, this function filtered the dropdown on the Settings &gt; Reading screen for selecting
</span><span class="cx">  * the page to show on front to include &quot;Activity Stream.&quot;
</span><span class="lines">@@ -700,4 +721,6 @@
</span><span class="cx">         if ( is_singular() &amp;&amp; bp_is_blog_page() &amp;&amp; get_option( 'thread_comments' ) )
</span><span class="cx">                 wp_enqueue_script( 'comment-reply' );
</span><span class="cx"> }
</span><ins>+endif;
+
</ins><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>