<!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][5223] trunk: Switch to use the WP Admin Bar by default.</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/5223">5223</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-10-08 18:46:09 +0000 (Sat, 08 Oct 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Switch to use the WP Admin Bar by default. See <a href="http://buddypress.trac.wordpress.org/ticket/3661">#3661</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreadminphp">trunk/bp-core/admin/bp-core-admin.php</a></li>
<li><a href="#trunkbpcoreadminbpcoreupdatephp">trunk/bp-core/admin/bp-core-update.php</a></li>
<li><a href="#trunkbpcorebpcorefunctionsphp">trunk/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunkbploaderphp">trunk/bp-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcoreadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-admin.php (5222 => 5223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-admin.php        2011-10-08 18:05:50 UTC (rev 5222)
+++ trunk/bp-core/admin/bp-core-admin.php        2011-10-08 18:46:09 UTC (rev 5223)
</span><span class="lines">@@ -78,6 +78,14 @@
</span><span class="cx">                 if ( !check_admin_referer('bp-admin') )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><ins>+                // &quot;Switch to Admin Bar&quot; is an optional option, so handle it here
+                if ( !empty( $_POST['bp-admin']['bp-force-buddybar'] ) ) {
+                        unset( $_POST['bp-admin']['bp-force-buddybar'] );
+
+                        // Switch to the WP Admin Bar by removing the BuddyBar override
+                        bp_delete_option( 'bp-force-buddybar' );
+                }
+
</ins><span class="cx">                 // Settings form submitted, now save the settings.
</span><span class="cx">                 foreach ( (array)$_POST['bp-admin'] as $key =&gt; $value )
</span><span class="cx">                         bp_update_option( $key, $value );
</span><span class="lines">@@ -163,6 +171,15 @@
</span><span class="cx"> 
</span><span class="cx">                                         &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><ins>+                                         &lt;?php if ( (bool) bp_get_option( 'bp-force-buddybar', false ) ) : ?&gt;
+                                                &lt;tr&gt;
+                                                        &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Switch the site to the WordPress Admin Bar?', 'buddypress' ); ?&gt;&lt;/th&gt;
+                                                        &lt;td&gt;
+                                                                &lt;input type=&quot;checkbox&quot; name=&quot;bp-admin[bp-force-buddybar]&quot; value=&quot;1&quot; id=&quot;bp-switch-to-admin-bar&quot; /&gt;
+                                                        &lt;/td&gt;
+                                                &lt;/tr&gt;
+                                        &lt;?php endif; ?&gt;
+
</ins><span class="cx">                                         &lt;?php do_action( 'bp_core_admin_screen_fields' ) ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;/tbody&gt;
</span></span></pre></div>
<a id="trunkbpcoreadminbpcoreupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-update.php (5222 => 5223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2011-10-08 18:05:50 UTC (rev 5222)
+++ trunk/bp-core/admin/bp-core-update.php        2011-10-08 18:46:09 UTC (rev 5223)
</span><span class="lines">@@ -84,11 +84,16 @@
</span><span class="cx">                         if ( $this-&gt;database_version &lt; (int) $this-&gt;new_version )
</span><span class="cx">                                 $steps[] = __( 'Database Update', 'buddypress' );
</span><span class="cx"> 
</span><ins>+                        // New for BP 1.5
</ins><span class="cx">                         if ( $this-&gt;database_version &lt; 1801 || !bp_core_get_directory_page_ids() ) {
</span><span class="cx">                                 $steps[] = __( 'Components', 'buddypress' );
</span><span class="cx">                                 $steps[] = __( 'Pages', 'buddypress' );
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        // New for BP 1.6
+                        if ( $this-&gt;database_version &lt; 5222 &amp;&amp; !defined( 'BP_USE_WP_ADMIN_BAR' ) )
+                                $steps[] = __( 'Admin Bar', 'buddypress' );
+
</ins><span class="cx">                         $steps[] = __( 'Finish', 'buddypress' );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -99,35 +104,40 @@
</span><span class="cx"> 
</span><span class="cx">                 // Save any posted values
</span><span class="cx">                 switch ( $step_name ) {
</span><del>-                        case 'db_update': default:
</del><ins>+                        case 'db_update':
</ins><span class="cx">                                 $result = $this-&gt;step_db_update_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'ms_update': default:
</del><ins>+                        case 'ms_update':
</ins><span class="cx">                                 $result = $this-&gt;step_ms_update_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'ms_pages': default:
</del><ins>+                        case 'ms_pages':
</ins><span class="cx">                                 $result = $this-&gt;step_ms_update_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'components': default:
</del><ins>+                        case 'components':
</ins><span class="cx">                                 $result = $this-&gt;step_components_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'pages': default:
</del><ins>+                        case 'pages':
</ins><span class="cx">                                 $result = $this-&gt;step_pages_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'permalinks': default:
</del><ins>+                        case 'permalinks':
</ins><span class="cx">                                 $result = $this-&gt;step_permalinks_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'theme': default:
</del><ins>+                        case 'theme':
</ins><span class="cx">                                 $result = $this-&gt;step_theme_save();
</span><span class="cx">                                 break;
</span><span class="cx"> 
</span><del>-                        case 'finish': default:
</del><ins>+                        case 'admin_bar':
+                                $result = $this-&gt;step_admin_bar_save();
+                                break;
+
+                        case 'finish':
+                        default:
</ins><span class="cx">                                 $result = $this-&gt;step_finish_save();
</span><span class="cx">                                 break;
</span><span class="cx">                 }
</span><span class="lines">@@ -232,10 +242,13 @@
</span><span class="cx">                                                         $this-&gt;step_theme();
</span><span class="cx">                                                         break;
</span><span class="cx"> 
</span><ins>+                                                case __( 'Admin Bar', 'buddypress' ) :
+                                                        $this-&gt;step_admin_bar();
+                                                        break;
+
</ins><span class="cx">                                                 case __( 'Finish', 'buddypress') :
</span><span class="cx">                                                         $this-&gt;step_finish();
</span><span class="cx">                                                         break;
</span><del>-
</del><span class="cx">                                         } ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;/div&gt;
</span><span class="lines">@@ -729,6 +742,37 @@
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * When upgrading to BP 1.6, prompt the admin to switch to WordPress' admin bar.
+         *
+         * @since 1.6
+         */
+        function step_admin_bar() {
+                if ( !current_user_can( 'activate_plugins' ) )
+                        return false;
+                ?&gt;
+
+                &lt;p&gt;&lt;?php _e( &quot;BuddyPress now uses WordPress' Admin Bar; this sits at the top of your site and contains various links to useful admin screens. We've turbo-charged the Admin Bar by adding social items to help your users explore your site, and manage their content.&quot;, 'buddypress' ); ?&gt;&lt;/p&gt;
+
+                &lt;p&gt;&lt;?php _e( &quot;We've noticed that your site uses the old bar from earlier versions of BuddyPress.&quot;, 'buddypress' ); ?&gt;&lt;/p&gt;
+
+                &lt;p&gt;
+                        &lt;label&gt;
+                                &lt;input type=&quot;checkbox&quot; name=&quot;keep_buddybar&quot; value=&quot;1&quot; /&gt;
+                                &lt;?php _e( &quot;If you'd prefer to not switch to the WordPress Admin bar just yet, check this box. Don't worry, you can change your mind later.&quot;, 'buddypress' ); ?&gt;
+                        &lt;/label&gt;
+                &lt;/p&gt;
+
+                &lt;div class=&quot;submit clear&quot;&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;save&quot; value=&quot;admin_bar&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;step&quot; value=&quot;&lt;?php echo esc_attr( $this-&gt;current_step ); ?&gt;&quot; /&gt;
+
+                        &lt;?php wp_nonce_field( 'bpwizard_admin_bar' ) ?&gt;
+                &lt;/div&gt;
+
+                &lt;?php
+        }
+
</ins><span class="cx">         function step_finish() {
</span><span class="cx">                 if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -1022,6 +1066,25 @@
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * When upgrading to BP 1.6, the admin is prompted to switch to WordPress' admin bar.
+         * If they choose not to, record that preference in the options table.
+         *
+         * @since 1.6
+         */
+        function step_admin_bar_save() {
+                if ( isset( $_POST['submit'] ) ) {
+                        check_admin_referer( 'bpwizard_admin_bar' );
+
+                        if ( !empty( $_POST['keep_buddybar'] ) )
+                                bp_update_option( 'bp-force-buddybar', 1 );
+
+                        return true;
+                }
+
+                return false;
+        }
+
</ins><span class="cx">         function step_finish_save() {
</span><span class="cx">                 if ( isset( $_POST['submit'] ) ) {
</span><span class="cx">                         check_admin_referer( 'bpwizard_finish' );
</span></span></pre></div>
<a id="trunkbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-functions.php (5222 => 5223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-functions.php        2011-10-08 18:05:50 UTC (rev 5222)
+++ trunk/bp-core/bp-core-functions.php        2011-10-08 18:46:09 UTC (rev 5223)
</span><span class="lines">@@ -1288,19 +1288,24 @@
</span><span class="cx">  * Should we use the WP admin bar?
</span><span class="cx">  *
</span><span class="cx">  * The WP Admin Bar, introduced in WP 3.1, is fully supported in BuddyPress as of BP 1.5.
</span><ins>+ * For BP 1.6, the WP Admin Bar is the default.
</ins><span class="cx">  *
</span><del>- * For the BP 1.5 development cycle, the BuddyBar will remain the default navigation for BP
- * installations. In the future, this behavior will be changed, so that the WP Admin Bar is the
- * default.
- *
- * @package BuddyPress
</del><ins>+ * @return bool False when WP Admin Bar support is disabled; true when enabled (default)
</ins><span class="cx">  * @since 1.5
</span><del>- *
</del><span class="cx">  * @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter
</span><del>- * @return bool False when WP Admin Bar support is disabled (default); true when enabled
</del><span class="cx">  */
</span><span class="cx"> function bp_use_wp_admin_bar() {
</span><del>-        return apply_filters( 'bp_use_wp_admin_bar', defined( 'BP_USE_WP_ADMIN_BAR' ) &amp;&amp; BP_USE_WP_ADMIN_BAR );
</del><ins>+        $use_admin_bar = true;
+
+        // Has the WP Admin Bar constant been explicity set?
+        if ( defined( 'BP_USE_WP_ADMIN_BAR' ) &amp;&amp; ! BP_USE_WP_ADMIN_BAR )
+                $use_admin_bar = false;
+
+        // Has the admin chosen to use the BuddyBar during an upgrade?
+        elseif ( (bool) bp_get_option( 'bp-force-buddybar', false ) )
+                $use_admin_bar = false;
+
+        return apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
</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 (5222 => 5223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2011-10-08 18:05:50 UTC (rev 5222)
+++ trunk/bp-loader.php        2011-10-08 18:46:09 UTC (rev 5223)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Define the database version
</span><span class="cx"> if ( !defined( 'BP_DB_VERSION' ) )
</span><del>-        define( 'BP_DB_VERSION', 3820 );
</del><ins>+        define( 'BP_DB_VERSION', 5222 );
</ins><span class="cx"> 
</span><span class="cx"> // Place your custom code (actions/filters) in a file called
</span><span class="cx"> // '/plugins/bp-custom.php' and it will be loaded before anything else.
</span></span></pre>
</div>
</div>

</body>
</html>