Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/16/2011 09:46:50 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Add bp_admin_url() function to handle site/network link creation. Add settings tabs to admin, and split component pages into their own dedicated page/tab.

File:
1 edited

Legend:

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

    r4652 r4662  
    239239    $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '' );
    240240    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Components', 'buddypress' ), __( 'Components', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup'  );
     241    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Pages',      'buddypress' ), __( 'Pages',      'buddypress' ), 'manage_options', 'bp-page-settings',    'bp_core_admin_page_setup'       );
    241242    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Settings',   'buddypress' ), __( 'Settings',   'buddypress' ), 'manage_options', 'bp-settings',         'bp_core_admin_settings'         );
    242243
     
    400401        // Create the string of links to the Edit Page screen for the pages
    401402        $edit_pages_links = array();
    402         foreach( $orphaned_pages as $op ) {
     403        foreach( $orphaned_pages as $op )
    403404            $edit_pages_links[] = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'post.php?action=edit&post=' . $op['id'] ), $op['title'] );
    404         }
    405 
    406         $admin_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php?page=bp-general-settings' ) : admin_url( 'admin.php?page=bp-general-settings' );
    407 
    408         $notice = sprintf( __( 'Some of your WordPress pages are linked to BuddyPress components that have been disabled. These pages may continue to show up in your site navigation. Consider <a href="%1$s">reactivating the components</a>, or unpublishing the pages: <strong>%2$s</strong>', 'buddypress' ), $admin_url, implode( ', ', $edit_pages_links ) );
     405
     406        $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
     407        $notice    = sprintf( __( 'Some of your WordPress pages are linked to BuddyPress Components that are disabled: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress' ), $admin_url, '<strong>' . implode( '</strong>, <strong>', $edit_pages_links ) . '</strong>' );
    409408
    410409        bp_core_add_admin_notice( $notice );
     
    449448
    450449    if ( !empty( $orphaned_components ) ) {
    451         $admin_url = bp_core_do_network_admin() ? network_admin_url( 'admin.php?page=bp-general-settings' ) : admin_url( 'admin.php?page=bp-general-settings' );
    452 
    453         $notice = sprintf( __( 'Some BuddyPress components must be associated with WordPress pages for your site to work properly. The following components are missing their required WP pages: <strong>%1$s</strong>. Visit the <a href="%2$s">BuddyPress Components</a> panel, where you can either deactivate unused components or complete the page setup.', 'buddypress' ), implode( ', ', $orphaned_components ), $admin_url );
     450        $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
     451        $notice    = sprintf( __( 'The following 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>' );
    454452
    455453        bp_core_add_admin_notice( $notice );
     
    12541252}
    12551253
     1254/**
     1255 * Output the correct URL based on BuddyPress and WordPress configuration
     1256 *
     1257 * @package BuddyPress
     1258 * @since 1.3
     1259 *
     1260 * @param string $path
     1261 * @param string $scheme
     1262 *
     1263 * @uses bp_get_admin_url()
     1264 */
     1265function bp_admin_url( $path = '', $scheme = 'admin' ) {
     1266    echo bp_get_admin_url( $path, $scheme );
     1267}
     1268    /**
     1269     * Return the correct URL based on BuddyPress and WordPress configuration
     1270     *
     1271     * @package BuddyPress
     1272     * @since 1.3
     1273     *
     1274     * @param string $path
     1275     * @param string $scheme
     1276     *
     1277     * @uses bp_core_do_network_admin()
     1278     * @uses network_admin_url()
     1279     * @uses admin_url()
     1280     */
     1281    function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
     1282
     1283        // Links belong in network admin
     1284        if ( bp_core_do_network_admin() )
     1285            $url = network_admin_url( $path, $scheme );
     1286
     1287        // Links belong in site admin
     1288        else
     1289            $url = admin_url( $path, $scheme );
     1290
     1291        return $url;
     1292    }
     1293
    12561294/** Global Manipulators *******************************************************/
    12571295
Note: See TracChangeset for help on using the changeset viewer.