<!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][6695] trunk/bp-core: Bring back bp_core_activation_notice() from the bench; it provides a notice for admins if pretty permalinks aren't enabled and/or the BP component/page mapping is incomplete.</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/6695">6695</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2012-12-30 16:27:02 +0000 (Sun, 30 Dec 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Bring back bp_core_activation_notice() from the bench; it provides a notice for admins if pretty permalinks aren't enabled and/or the BP component/page mapping is incomplete. See <a href="http://buddypress.trac.wordpress.org/ticket/4671">#4671</a>.
These notices are helpful for debugging people's sites on the support forums, and for telling people they need to set permalinks. Most (all?) of this will be taken back out in a future version of BuddyPress when we switch to using rewrite rules.
This commit also accidentally fixes a regression in trunk where, if the Blogs component is active on multisite, we weren't recording existing blogs' information for use in the Sites Directory.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreactionsphp">trunk/bp-core/admin/bp-core-actions.php</a></li>
<li><a href="#trunkbpcoreadminbpcorefunctionsphp">trunk/bp-core/admin/bp-core-functions.php</a></li>
<li><a href="#trunkbpcoredeprecated17php">trunk/bp-core/deprecated/1.7.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcoreactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-actions.php (6694 => 6695)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-actions.php        2012-12-30 14:36:35 UTC (rev 6694)
+++ trunk/bp-core/admin/bp-core-actions.php        2012-12-30 16:27:02 UTC (rev 6695)
</span><span class="lines">@@ -49,11 +49,12 @@
</span><span class="cx"> add_action( 'wpmu_new_blog', 'bp_new_site', 10, 6 );
</span><span class="cx">
</span><span class="cx"> // Hook on to admin_init
</span><del>-add_action( 'bp_admin_init', 'bp_setup_updater', 999 );
-add_action( 'bp_admin_init', 'bp_register_importers' );
-add_action( 'bp_admin_init', 'bp_register_admin_style' );
-add_action( 'bp_admin_init', 'bp_register_admin_settings' );
-add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 );
</del><ins>+add_action( 'bp_admin_init', 'bp_setup_updater', 1000 );
+add_action( 'bp_admin_init', 'bp_core_activation_notice', 1010 );
+add_action( 'bp_admin_init', 'bp_register_importers' );
+add_action( 'bp_admin_init', 'bp_register_admin_style' );
+add_action( 'bp_admin_init', 'bp_register_admin_settings' );
+add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 );
</ins><span class="cx">
</span><span class="cx"> // Add a new separator
</span><span class="cx"> add_action( 'bp_admin_menu', 'bp_admin_separator' );
</span></span></pre></div>
<a id="trunkbpcoreadminbpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-functions.php (6694 => 6695)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-functions.php        2012-12-30 14:36:35 UTC (rev 6694)
+++ trunk/bp-core/admin/bp-core-functions.php        2012-12-30 16:27:02 UTC (rev 6695)
</span><span class="lines">@@ -162,6 +162,134 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Verify that some BP prerequisites are set up properly, and notify the admin if not
+ *
+ * On every Dashboard page, this function checks the following:
+ * - that pretty permalinks are enabled
+ * - that every BP component that needs a WP page for a directory has one
+ * - that no WP page has multiple BP components associated with it
+ * The administrator will be shown a notice for each check that fails.
+ *
+ * @global WPDB $wpdb WordPress DB object
+ * @global WP_Rewrite $wp_rewrite
+ * @since BuddyPress (1.2)
+ */
+function bp_core_activation_notice() {
+        global $wpdb, $wp_rewrite;
+
+        $bp = buddypress();
+
+        // Only the super admin gets warnings
+        if ( !bp_current_user_can( 'bp_moderate' ) )
+                return;
+
+        // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden
+        if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
+                return;
+
+        /**
+         * Check to make sure that the blog setup routine has run. This can't happen during the
+         * wizard because of the order which the components are loaded. We check for multisite here
+         * on the off chance that someone has activated the blogs component and then disabled MS
+         */
+        if ( bp_is_active( 'blogs' ) ) {
+                $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" );
+
+                if ( empty( $count ) ) {
+                        bp_blogs_record_existing_blogs();
+                }
+        }
+
+        /**
+         * Are pretty permalinks enabled?
+         */
+        if ( isset( $_POST['permalink_structure'] ) )
+                return;
+
+        if ( empty( $wp_rewrite->permalink_structure ) ) {
+                bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
+        }
+
+        /**
+         * Check for orphaned BP components (BP component is enabled, no WP page exists)
+         */
+        $orphaned_components = array();
+        $wp_page_components = array();
+
+        // Only components with 'has_directory' require a WP page to function
+        foreach( array_keys( $bp->loaded_components ) as $component_id ) {
+                if ( !empty( $bp->{$component_id}->has_directory ) ) {
+                        $wp_page_components[] = array(
+                                'id' => $component_id,
+                                'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id )
+                        );
+                }
+        }
+
+        // Activate and Register are special cases. They are not components but they need WP pages.
+        // If user registration is disabled, we can skip this step.
+        if ( bp_get_signup_allowed() ) {
+                $wp_page_components[] = array(
+                        'id' => 'activate',
+                        'name' => __( 'Activate', 'buddypress' )
+                );
+
+                $wp_page_components[] = array(
+                        'id' => 'register',
+                        'name' => __( 'Register', 'buddypress' )
+                );
+        }
+
+        // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message.
+        if ( empty( $bp->pages->members ) )
+                $bp->pages = bp_core_get_directory_pages();
+
+        foreach( $wp_page_components as $component ) {
+                if ( !isset( $bp->pages->{$component['id']} ) ) {
+                        $orphaned_components[] = $component['name'];
+                }
+        }
+
+        // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
+        // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
+        // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292
+        if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) {
+                $forum_key = array_search( $bp->forums->name, $orphaned_components );
+                unset( $orphaned_components[$forum_key] );
+                $orphaned_components = array_values( $orphaned_components );
+        }
+
+        if ( !empty( $orphaned_components ) ) {
+                $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
+                $notice = sprintf( __( 'The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $orphaned_components ) . '</strong>' );
+
+                bp_core_add_admin_notice( $notice );
+        }
+
+        // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found.
+        $dupe_names = array();
+        $page_ids = (array)bp_core_get_directory_page_ids();
+        $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) );
+
+        if ( !empty( $dupes ) ) {
+                foreach( array_keys( $dupes ) as $dupe_component ) {
+                        $dupe_names[] = $bp->pages->{$dupe_component}->title;
+                }
+
+                // Make sure that there are no duplicate duplicates :)
+                $dupe_names = array_unique( $dupe_names );
+        }
+
+        // If there are duplicates, post a message about them
+        if ( !empty( $dupe_names ) ) {
+                $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
+                $notice = sprintf( __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $dupe_names ) . '</strong>' );
+
+                bp_core_add_admin_notice( $notice );
+        }
+}
+
+/**
</ins><span class="cx"> * Redirect user to BuddyPress's What's New page on activation
</span><span class="cx"> *
</span><span class="cx"> * @since BuddyPress (1.7)
</span></span></pre></div>
<a id="trunkbpcoredeprecated17php"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/deprecated/1.7.php (6694 => 6695)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/deprecated/1.7.php        2012-12-30 14:36:35 UTC (rev 6694)
+++ trunk/bp-core/deprecated/1.7.php        2012-12-30 16:27:02 UTC (rev 6695)
</span><span class="lines">@@ -116,138 +116,6 @@
</span><span class="cx"> /** Admin *********************************************************************/
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Verify that some BP prerequisites are set up properly, and notify the admin if not
- *
- * On every Dashboard page, this function checks the following:
- * - that pretty permalinks are enabled
- * - that a BP-compatible theme is activated
- * - that every BP component that needs a WP page for a directory has one
- * - that no WP page has multiple BP components associated with it
- * The administrator will be shown a notice for each check that fails.
- *
- * @deprecated BuddyPress (1.7)
- * @package BuddyPress Core
- */
-function bp_core_activation_notice() {
-        global $wp_rewrite, $wpdb;
-
-        $bp = buddypress();
-
-        // Only the super admin gets warnings
-        if ( !bp_current_user_can( 'bp_moderate' ) )
-                return;
-
-        // On multisite installs, don't load on a non-root blog, unless do_network_admin is
-        // overridden
-        if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() )
-                return;
-
-        // Don't show these messages during setup or upgrade
-        if ( !empty( $bp->maintenance_mode ) )
-                return;
-
-        /**
-         * Check to make sure that the blog setup routine has run. This can't happen during the
-         * wizard because of the order which the components are loaded. We check for multisite here
-         * on the off chance that someone has activated the blogs component and then disabled MS
-         */
-        if ( bp_is_active( 'blogs' ) ) {
-                $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" );
-
-                if ( empty( $count ) ) {
-                        bp_blogs_record_existing_blogs();
-                }
-        }
-
-        /**
-         * Are pretty permalinks enabled?
-         */
-        if ( isset( $_POST['permalink_structure'] ) )
-                return false;
-
-        if ( empty( $wp_rewrite->permalink_structure ) ) {
-                bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
-        }
-
-        /**
-         * Check for orphaned BP components (BP component is enabled, no WP page exists)
-         */
-        $orphaned_components = array();
-        $wp_page_components = array();
-
-        // Only components with 'has_directory' require a WP page to function
-        foreach( array_keys( $bp->loaded_components ) as $component_id ) {
-                if ( !empty( $bp->{$component_id}->has_directory ) ) {
-                        $wp_page_components[] = array(
-                                'id' => $component_id,
-                                'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id )
-                        );
-                }
-        }
-
-        // Activate and Register are special cases. They are not components but they need WP pages.
-        // If user registration is disabled, we can skip this step.
-        if ( bp_get_signup_allowed() ) {
-                $wp_page_components[] = array(
-                        'id' => 'activate',
-                        'name' => __( 'Activate', 'buddypress' )
-                );
-
-                $wp_page_components[] = array(
-                        'id' => 'register',
-                        'name' => __( 'Register', 'buddypress' )
-                );
-        }
-
-        foreach( $wp_page_components as $component ) {
-                if ( !isset( $bp->pages->{$component['id']} ) ) {
-                        $orphaned_components[] = $component['name'];
-                }
-        }
-
-        // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
-        // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
-        // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292
-        if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) {
-                $forum_key = array_search( $bp->forums->name, $orphaned_components );
-                unset( $orphaned_components[$forum_key] );
-                $orphaned_components = array_values( $orphaned_components );
-        }
-
-        if ( !empty( $orphaned_components ) ) {
-                $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
-                $notice = sprintf( __( 'The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $orphaned_components ) . '</strong>' );
-
-                bp_core_add_admin_notice( $notice );
-        }
-
-        /**
-         * BP components cannot share a single WP page. Check for duplicate assignments, and post
-         * a message if found.
-         */
-        $dupe_names = array();
-        $page_ids = (array)bp_core_get_directory_page_ids();
-        $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) );
-
-        if ( !empty( $dupes ) ) {
-                foreach( array_keys( $dupes ) as $dupe_component ) {
-                        $dupe_names[] = $bp->pages->{$dupe_component}->title;
-                }
-
-                // Make sure that there are no duplicate duplicates :)
-                $dupe_names = array_unique( $dupe_names );
-        }
-
-        // If there are duplicates, post a message about them
-        if ( !empty( $dupe_names ) ) {
-                $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
-                $notice = sprintf( __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $dupe_names ) . '</strong>' );
-
-                bp_core_add_admin_notice( $notice );
-        }
-}
-
-/**
</del><span class="cx"> * This function was originally used to update pre-1.1 schemas, but that was
</span><span class="cx"> * before we had a legitimate update process.
</span><span class="cx"> *
</span></span></pre>
</div>
</div>
</body>
</html>