<!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][6401] trunk: Theme Compat:</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/6401">6401</a></dd>
<dt>Author</dt> <dd>r-a-y</dd>
<dt>Date</dt> <dd>2012-10-13 07:00:54 +0000 (Sat, 13 Oct 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Theme Compat:

* Introduce BP_Registration_Theme_Compat class - Adds registration / activation template support to theme compat.

* Remove headers in bp-legacy register.php and activate.php template files as this is now handled by the_title().

* Fix notice during signup when the XProfile component was disabled

* See <a href="http://buddypress.trac.wordpress.org/ticket/3741">#3741</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmembersbpmembersscreensphp">trunk/bp-members/bp-members-screens.php</a></li>
<li><a href="#trunkbpthemesbplegacybuddypressmembersactivatephp">trunk/bp-themes/bp-legacy/buddypress/members/activate.php</a></li>
<li><a href="#trunkbpthemesbplegacybuddypressmembersregisterphp">trunk/bp-themes/bp-legacy/buddypress/members/register.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpmembersbpmembersscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-screens.php (6400 => 6401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-screens.php        2012-10-13 06:36:31 UTC (rev 6400)
+++ trunk/bp-members/bp-members-screens.php        2012-10-13 07:00:54 UTC (rev 6401)
</span><span class="lines">@@ -160,32 +160,35 @@
</span><span class="cx"> 
</span><span class="cx">                         if ( 'none' != $active_signup ) {
</span><span class="cx"> 
</span><del>-                                // Let's compact any profile field info into usermeta
-                                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
</del><ins>+                                // Make sure the extended profiles module is enabled
+                                if ( bp_is_active( 'xprofile' ) ) {
+                                        // Let's compact any profile field info into usermeta
+                                        $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
</ins><span class="cx"> 
</span><del>-                                // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
-                                foreach ( (array) $profile_field_ids as $field_id ) {
-                                        if ( ! isset( $_POST['field_' . $field_id] ) ) {
</del><ins>+                                        // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
+                                        foreach ( (array) $profile_field_ids as $field_id ) {
+                                                if ( ! isset( $_POST['field_' . $field_id] ) ) {
</ins><span class="cx"> 
</span><del>-                                                if ( ! empty( $_POST['field_' . $field_id . '_day'] ) &amp;&amp; ! empty( $_POST['field_' . $field_id . '_month'] ) &amp;&amp; ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
-                                                        // Concatenate the values
-                                                        $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
</del><ins>+                                                        if ( ! empty( $_POST['field_' . $field_id . '_day'] ) &amp;&amp; ! empty( $_POST['field_' . $field_id . '_month'] ) &amp;&amp; ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
+                                                                // Concatenate the values
+                                                                $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
</ins><span class="cx"> 
</span><del>-                                                        // Turn the concatenated value into a timestamp
-                                                        $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
</del><ins>+                                                                // Turn the concatenated value into a timestamp
+                                                                $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
+                                                        }
</ins><span class="cx">                                                 }
</span><ins>+
+                                                if ( !empty( $_POST['field_' . $field_id] ) )
+                                                        $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
+
+                                                if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
+                                                        $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
</ins><span class="cx">                                         }
</span><span class="cx"> 
</span><del>-                                        if ( !empty( $_POST['field_' . $field_id] ) )
-                                                $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
-                                        
-                                        if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
-                                                $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
</del><ins>+                                        // Store the profile field ID's in usermeta
+                                        $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
</ins><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                // Store the profile field ID's in usermeta
-                                $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
-
</del><span class="cx">                                 // Hash and store the password
</span><span class="cx">                                 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
</span><span class="cx"> 
</span><span class="lines">@@ -203,7 +206,7 @@
</span><span class="cx"> 
</span><span class="cx">                                 if ( is_wp_error( $wp_user_id ) ) {
</span><span class="cx">                                         $bp-&gt;signup-&gt;step = 'request-details';
</span><del>-                                        bp_core_add_message( $wp_user_id-&gt;get_error_message(), 'error' ); 
</del><ins>+                                        bp_core_add_message( $wp_user_id-&gt;get_error_message(), 'error' );
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         $bp-&gt;signup-&gt;step = 'completed-confirmation';
</span><span class="cx">                                 }
</span><span class="lines">@@ -370,3 +373,97 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> new BP_Members_Theme_Compat();
</span><ins>+
+/**
+ * The main theme compat class for BuddyPress Registration.
+ *
+ * This class sets up the necessary theme compatability actions to safely output
+ * registration template parts to the_title and the_content areas of a theme.
+ *
+ * @since BuddyPress (1.7)
+ */
+class BP_Registration_Theme_Compat {
+
+        /**
+         * Setup the groups component theme compatibility
+         *
+         * @since BuddyPress (1.7)
+         */
+        public function __construct() {
+                add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) );
+        }
+
+        /**
+         * Are we looking at either the registration or activation pages?
+         *
+         * @since BuddyPress (1.7)
+         */
+        public function is_registration() {
+
+                // Bail if not looking at the registration or activation page
+                if ( ! bp_is_register_page() &amp;&amp; ! bp_is_activation_page() ) {
+                        return;
+                }
+
+                // Not a directory
+                bp_update_is_directory( false, 'register' );
+
+                // Setup actions
+                add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
+                add_filter( 'bp_replace_the_content',                    array( $this, 'dummy_content' ) );
+        }
+
+        /** Template ***********************************************************/
+
+        /**
+         * Update the global $post with dummy data
+         *
+         * @since BuddyPress (1.7)
+         */
+        public function dummy_post() {
+                // Registration page
+                if ( bp_is_register_page() ) {
+                        $title = __( 'Create an Account', 'buddypress' );
+
+                        if ( 'completed-confirmation' == bp_get_current_signup_step() ) {
+                                $title = __( 'Sign Up Complete!', 'buddypress' );
+                        }
+
+                // Activation page
+                } else {
+                        $title = __( 'Activate your Account', 'buddypress' );
+
+                        if ( bp_account_was_activated() ) {
+                                $title = __( 'Account Activated', 'buddypress' );
+                        }
+                }
+
+                $post_type = bp_is_register_page() ? 'bp_register' : 'bp_activate';
+
+                bp_theme_compat_reset_post( array(
+                        'ID'             =&gt; 0,
+                        'post_title'     =&gt; $title,
+                        'post_author'    =&gt; 0,
+                        'post_date'      =&gt; 0,
+                        'post_content'   =&gt; '',
+                        'post_type'      =&gt; $post_type,
+                        'post_status'    =&gt; 'publish',
+                        'is_archive'     =&gt; true,
+                        'comment_status' =&gt; 'closed'
+                ) );
+        }
+
+        /**
+         * Filter the_content with either the register or activate templates.
+         *
+         * @since BuddyPress (1.7)
+         */
+        public function dummy_content() {
+                if ( bp_is_register_page() ) {
+                        bp_buffer_template_part( 'members/register' );
+                } else {
+                        bp_buffer_template_part( 'members/activate' );
+                }
+        }
+}
+new BP_Registration_Theme_Compat();
</ins></span></pre></div>
<a id="trunkbpthemesbplegacybuddypressmembersactivatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-legacy/buddypress/members/activate.php (6400 => 6401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-legacy/buddypress/members/activate.php        2012-10-13 06:36:31 UTC (rev 6400)
+++ trunk/bp-themes/bp-legacy/buddypress/members/activate.php        2012-10-13 07:00:54 UTC (rev 6401)
</span><span class="lines">@@ -6,8 +6,6 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php if ( bp_account_was_activated() ) : ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;h2 class=&quot;widgettitle&quot;&gt;&lt;?php _e( 'Account Activated', 'buddypress' ); ?&gt;&lt;/h2&gt;
-
</del><span class="cx">                         &lt;?php do_action( 'bp_before_activate_content' ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php if ( isset( $_GET['e'] ) ) : ?&gt;
</span><span class="lines">@@ -18,8 +16,6 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php else : ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;h3&gt;&lt;?php _e( 'Activate your Account', 'buddypress' ); ?&gt;&lt;/h3&gt;
-
</del><span class="cx">                         &lt;?php do_action( 'bp_before_activate_content' ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;p&gt;&lt;?php _e( 'Please provide a valid activation key.', 'buddypress' ); ?&gt;&lt;/p&gt;
</span></span></pre></div>
<a id="trunkbpthemesbplegacybuddypressmembersregisterphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-legacy/buddypress/members/register.php (6400 => 6401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-legacy/buddypress/members/register.php        2012-10-13 06:36:31 UTC (rev 6400)
+++ trunk/bp-themes/bp-legacy/buddypress/members/register.php        2012-10-13 07:00:54 UTC (rev 6401)
</span><span class="lines">@@ -17,8 +17,6 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php if ( 'request-details' == bp_get_current_signup_step() ) : ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;h2&gt;&lt;?php _e( 'Create an Account', 'buddypress' ); ?&gt;&lt;/h2&gt;
-
</del><span class="cx">                         &lt;?php do_action( 'template_notices' ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;p&gt;&lt;?php _e( 'Registering for this site is easy, just fill in the fields below and we\'ll get a new account set up for you in no time.', 'buddypress' ); ?&gt;&lt;/p&gt;
</span><span class="lines">@@ -169,7 +167,7 @@
</span><span class="cx">                                                         &lt;?php else : ?&gt;
</span><span class="cx">                                                                 &lt;p class=&quot;field-visibility-settings-notoggle&quot; id=&quot;field-visibility-settings-toggle-&lt;?php bp_the_profile_field_id() ?&gt;&quot;&gt;
</span><span class="cx">                                                                         &lt;?php printf( __( 'This field can be seen by: &lt;span class=&quot;current-visibility-level&quot;&gt;%s&lt;/span&gt;', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?&gt;
</span><del>-                                                                &lt;/p&gt;                        
</del><ins>+                                                                &lt;/p&gt;
</ins><span class="cx">                                                         &lt;?php endif ?&gt;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -246,8 +244,6 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;h2&gt;&lt;?php _e( 'Sign Up Complete!', 'buddypress' ); ?&gt;&lt;/h2&gt;
-
</del><span class="cx">                         &lt;?php do_action( 'template_notices' ); ?&gt;
</span><span class="cx">                         &lt;?php do_action( 'bp_before_registration_confirmed' ); ?&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>