<!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][5300] trunk: Attach component creation to 'bp_setup_component' action.</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><a href="http://buddypress.trac.wordpress.org/changeset/5300">5300</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-11-08 00:11:29 +0000 (Tue, 08 Nov 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Attach component creation to 'bp_setup_component' action. Clean up bp-core-hooks.php and include new 'bp_setup_component' hook. Fixes issue with $bp reference in global scope in each component. See <a href="http://buddypress.trac.wordpress.org/ticket/3738">#3738</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityloaderphp">trunk/bp-activity/bp-activity-loader.php</a></li>
<li><a href="#trunkbpblogsbpblogsloaderphp">trunk/bp-blogs/bp-blogs-loader.php</a></li>
<li><a href="#trunkbpcorebpcorehooksphp">trunk/bp-core/bp-core-hooks.php</a></li>
<li><a href="#trunkbpcorebpcoreloaderphp">trunk/bp-core/bp-core-loader.php</a></li>
<li><a href="#trunkbpforumsbpforumsloaderphp">trunk/bp-forums/bp-forums-loader.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsloaderphp">trunk/bp-friends/bp-friends-loader.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsloaderphp">trunk/bp-groups/bp-groups-loader.php</a></li>
<li><a href="#trunkbpmembersbpmembersloaderphp">trunk/bp-members/bp-members-loader.php</a></li>
<li><a href="#trunkbpmessagesbpmessagesloaderphp">trunk/bp-messages/bp-messages-loader.php</a></li>
<li><a href="#trunkbpsettingsbpsettingsloaderphp">trunk/bp-settings/bp-settings-loader.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileloaderphp">trunk/bp-xprofile/bp-xprofile-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-activity/bp-activity-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -330,6 +330,11 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// Create the activity component
-$bp->activity = new BP_Activity_Component();
</del><ins>+function bp_setup_activity() {
+        global $bp;
+
+        $bp->activity = new BP_Activity_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_activity', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpblogsbpblogsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs/bp-blogs-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs/bp-blogs-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-blogs/bp-blogs-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -191,7 +191,11 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the blogs component
-$bp->blogs = new BP_Blogs_Component();
</del><span class="cx">
</span><ins>+function bp_setup_blogs() {
+        global $bp;
+        $bp->blogs = new BP_Blogs_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_blogs', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorebpcorehooksphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-hooks.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-hooks.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-core/bp-core-hooks.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -2,42 +2,76 @@
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><del>-/** Loaded ********************************************************************/
</del><ins>+/**
+ * BuddyPress Filters & Actions
+ *
+ * @package BuddyPress
+ * @subpackage Hooks
+ *
+ * This file contains the actions and filters that are used through-out BuddyPress.
+ * They are consolidated here to make searching for them easier, and to help
+ * developers understand at a glance the order in which things occur.
+ *
+ */
</ins><span class="cx">
</span><del>-add_action( 'plugins_loaded', 'bp_loaded', 10 );
</del><ins>+// Exit if accessed directly
+if ( !defined( 'ABSPATH' ) ) exit;
</ins><span class="cx">
</span><del>-add_action( 'bp_loaded', 'bp_include', 2 );
</del><ins>+/** ACTIONS *******************************************************************/
</ins><span class="cx">
</span><del>-add_action( 'wp', 'bp_actions', 3 );
</del><ins>+/**
+ * Attach BuddyPress to WordPress
+ *
+ * BuddyPress uses its own internal actions to help aid in additional plugin
+ * development, and to limit the amount of potential future code changes when
+ * updates to WordPress occur.
+ */
+add_action( 'plugins_loaded', 'bp_loaded', 10 );
+add_action( 'init', 'bp_init', 10 );
+add_action( 'wp', 'bp_ready', 10 );
+//add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
+//add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts', 10 );
+//add_filter( 'template_include', 'bp_template_include', 10 );
</ins><span class="cx">
</span><del>-add_action( 'wp', 'bp_screens', 4 );
</del><ins>+/**
+ * bp_loaded - Attached to 'plugins_loaded' above
+ *
+ * Attach various loader actions to the bp_loaded action.
+ * The load order helps to execute code at the correct time.
+ * v---Load order
+ */
+add_action( 'bp_loaded', 'bp_setup_components', 2 );
+add_action( 'bp_loaded', 'bp_include', 4 );
+add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
+add_action( 'bp_loaded', 'bp_core_load_admin_bar', 10 );
</ins><span class="cx">
</span><del>-/** Init **********************************************************************/
</del><ins>+/**
+ * bp_init - Attached to 'init' above
+ *
+ * Attach various initialization actions to the bp_init action.
+ * The load order helps to execute code at the correct time.
+ * v---Load order
+ */
+add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
+add_action( 'bp_init', 'bp_setup_globals', 4 );
+add_action( 'bp_init', 'bp_setup_nav', 6 );
+add_action( 'bp_init', 'bp_setup_title', 8 );
</ins><span class="cx">
</span><del>-// Attach bp_init to WordPress init
-add_action( 'init', 'bp_init' );
</del><ins>+/**
+ * bp_ready - Attached to 'wp' above
+ *
+ * Attach various initialization actions to the bp_init action.
+ * The load order helps to execute code at the correct time.
+ * v---Load order
+ */
+add_action( 'bp_ready', 'bp_actions', 2 );
+add_action( 'bp_ready', 'bp_screens', 4 );
</ins><span class="cx">
</span><del>-// Parse the URI and set globals
-add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
</del><ins>+/** Admin Bar *****************************************************************/
</ins><span class="cx">
</span><del>-// Setup component globals
-add_action( 'bp_init', 'bp_setup_globals', 4 );
-
</del><span class="cx"> // Setup the navigation menu
</span><del>-add_action( 'bp_init', 'bp_setup_nav', 7 );
-
-// Setup the navigation menu
</del><span class="cx"> add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 11 );
</span><span class="cx">
</span><del>-// Setup the title
-add_action( 'bp_init', 'bp_setup_title', 9 );
-
-// Setup widgets
-add_action( 'bp_loaded', 'bp_setup_widgets' );
-
-// Setup admin bar
-add_action( 'bp_loaded', 'bp_core_load_admin_bar' );
-
</del><span class="cx"> /** The hooks *****************************************************************/
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -48,6 +82,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Include files on this action
+ */
+function bp_setup_components() {
+        do_action( 'bp_setup_components' );
+}
+
+/**
</ins><span class="cx"> * Setup global variables and objects
</span><span class="cx"> */
</span><span class="cx"> function bp_setup_globals() {
</span><span class="lines">@@ -98,6 +139,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Attached to wp
+ */
+function bp_ready() {
+        do_action( 'bp_ready' );
+}
+
+/**
</ins><span class="cx"> * Attach potential template actions
</span><span class="cx"> */
</span><span class="cx"> function bp_actions() {
</span></span></pre></div>
<a id="trunkbpcorebpcoreloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-core/bp-core-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -229,7 +229,10 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// Initialize the BuddyPress Core
-$bp->core = new BP_Core();
</del><ins>+function bp_setup_core() {
+        global $bp;
+        $bp->core = new BP_Core();
+}
+add_action( 'bp_setup_components', 'bp_setup_core', 2 );
</ins><span class="cx">
</span><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpforumsbpforumsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-forums/bp-forums-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -247,7 +247,12 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the forums component
-$bp->forums = new BP_Forums_Component();
</del><span class="cx">
</span><ins>+function bp_setup_forums() {
+        global $bp;
+
+        $bp->forums = new BP_Forums_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_forums', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpfriendsbpfriendsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-friends/bp-friends-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -206,7 +206,11 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the friends component
-$bp->friends = new BP_Friends_Component();
</del><span class="cx">
</span><ins>+function bp_setup_friends() {
+        global $bp;
+        $bp->friends = new BP_Friends_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_friends', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-groups/bp-groups-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -471,7 +471,13 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the groups component
-$bp->groups = new BP_Groups_Component();
</del><span class="cx">
</span><ins>+
+function bp_setup_groups() {
+        global $bp;
+
+        $bp->groups = new BP_Groups_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_groups', 6 );
+
</ins><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkbpmembersbpmembersloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-members/bp-members-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -185,9 +185,12 @@
</span><span class="cx">
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><ins>+}
</ins><span class="cx">
</span><ins>+function bp_setup_members() {
+        global $bp;
+        $bp->members = new BP_Members_Component();
</ins><span class="cx"> }
</span><del>-// Create the users component
-$bp->members = new BP_Members_Component();
</del><ins>+add_action( 'bp_setup_components', 'bp_setup_members', 1 );
</ins><span class="cx">
</span><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpmessagesbpmessagesloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-messages/bp-messages-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -251,7 +251,11 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the messages component
-$bp->messages = new BP_Messages_Component();
</del><span class="cx">
</span><ins>+function bp_setup_messages() {
+        global $bp;
+        $bp->messages = new BP_Messages_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_messages', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpsettingsbpsettingsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-settings/bp-settings-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -181,7 +181,11 @@
</span><span class="cx">                 parent::setup_admin_bar( $wp_admin_nav );
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the settingss component
-$bp->settings = new BP_Settings_Component();
</del><span class="cx">
</span><ins>+function bp_setup_settings() {
+        global $bp;
+        $bp->settings = new BP_Settings_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_settings', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-loader.php (5299 => 5300)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-loader.php        2011-11-07 19:31:13 UTC (rev 5299)
+++ trunk/bp-xprofile/bp-xprofile-loader.php        2011-11-08 00:11:29 UTC (rev 5300)
</span><span class="lines">@@ -230,8 +230,13 @@
</span><span class="cx">                 parent::setup_title();
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-// Create the xprofile component
-if ( !isset( $bp->profile->id ) )
-        $bp->profile = new BP_XProfile_Component();
</del><span class="cx">
</span><ins>+function bp_setup_xprofile() {
+        global $bp;
+
+        if ( !isset( $bp->profile->id ) )
+                $bp->profile = new BP_XProfile_Component();
+}
+add_action( 'bp_setup_components', 'bp_setup_xprofile', 6 );
+
</ins><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>