Skip to:
Content

BuddyPress.org

Changeset 5028


Ignore:
Timestamp:
08/24/2011 04:12:26 PM (13 years ago)
Author:
boonebgorges
Message:

Adds admin warning when a WP pages is associated with multiple BP components. Fixes #3508

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-functions.php

    r5026 r5028  
    327327 *   - that a BP-compatible theme is activated
    328328 *   - that every BP component that needs a WP page for a directory has one
    329  *   - that no directory WP pages are published for deactivated components
     329 *   - that no WP page has multiple BP components associated with it
    330330 * The administrator will be shown a notice for each check that fails.
    331331 *
     
    423423        $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
    424424        $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>' );
     425
     426        bp_core_add_admin_notice( $notice );
     427    }
     428
     429    /**
     430     * BP components cannot share a single WP page. Check for duplicate assignments, and post
     431     * a message if found.
     432     */
     433    $dupe_names = array();
     434    $page_ids   = (array)bp_core_get_directory_page_ids();
     435    $dupes      = array_diff_assoc( $page_ids, array_unique( $page_ids ) );
     436
     437    if ( !empty( $dupes ) ) {
     438        foreach( $dupes as $dupe_component => $dupe_id ) {
     439            $dupe_names[] = $bp->pages->{$dupe_component}->title;
     440        }
     441
     442        // Make sure that there are no duplicate duplicates :)
     443        $dupe_names = array_unique( $dupe_names );
     444    }
     445
     446    // If there are duplicates, post a message about them
     447    if ( !empty( $dupe_names ) ) {
     448        $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
     449        $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>' );
    425450
    426451        bp_core_add_admin_notice( $notice );
Note: See TracChangeset for help on using the changeset viewer.