Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2012 08:25:00 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Legacy Group Forums:

  • Retire bbPress 1.1 group forums component.
  • Creates new "Retired" components group, where old components go to die.
  • Deprecate "Forums" settings tab; use Legacy Forums Setting instead.
  • Remove associated code for old forums admin UI.
  • See #4493.
  • Fixes #3598.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-components.php

    r6558 r6581  
    5050function bp_core_admin_components_options() {
    5151
    52     // Load core functions, if needed
    53     if ( !function_exists( 'bp_get_option' ) )
    54         require( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    55 
    5652    // Declare local variables
    5753    $deactivated_components = array();
     
    7874    );
    7975
     76    // Retired components
     77    $retired_components['forums'] = array(
     78        'title'       => __( 'Group Forums', 'buddypress' ),
     79        'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="http://bbpress.org">bbPress</a>' )
     80    );
     81
    8082    // Optional core components
    8183    $optional_components = array(
     
    105107        ),
    106108        'forums'   => array(
    107             'title'       => __( 'Discussion Forums', 'buddypress' ),
    108             'description' => __( 'Site-wide and Group forums allow for focused, bulletin-board style conversations. Powered by bbPress.', 'buddypress' )
     109            'title'       => __( 'Group Forums (Legacy)', 'buddypress' ),
     110            'description' => __( 'Group forums allow for focused, bulletin-board style conversations.', 'buddypress' )
    109111        ),
    110112        'blogs'    => array(
     
    114116    );
    115117
     118    // Don't show Forums component in optional components if it's disabled
     119    if ( ! bp_is_active( 'forums' ) ) {
     120        unset( $optional_components['forums'] );
     121    }
     122   
    116123    // Add blogs tracking if multisite
    117124    if ( is_multisite() ) {
     
    130137            // Trim off namespace and filename
    131138            $trimmed = array();
    132             foreach ( (array) $deactivated_components as $component => $value ) {
     139            foreach ( array_keys( (array) $deactivated_components ) as $component ) {
    133140                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
    134141            }
    135142
    136143            // Loop through the optional components to create an active component array
    137             foreach ( (array) $optional_components as $ocomponent => $ovalue ) {
     144            foreach ( array_keys( (array) $optional_components ) as $ocomponent ) {
    138145                if ( !in_array( $ocomponent, $trimmed ) ) {
    139146                    $active_components[$ocomponent] = 1;
     
    176183            $current_components = $required_components;
    177184            break;
     185        case 'retired' :
     186            $current_components = $retired_components;
     187            break;
    178188    } ?>
    179189
     
    182192        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'active'   ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'active'   ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Active <span class="count">(%s)</span>',   'Active <span class="count">(%s)</span>',   count( $active_components   ), 'buddypress' ), number_format_i18n( count( $active_components   ) ) ); ?></a> | </li>
    183193        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'inactive' ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'inactive' ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ), number_format_i18n( count( $inactive_components ) ) ); ?></a> | </li>
    184         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a></li>
     194        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a> | </li>
     195        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'retired'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'retired'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Retired <span class="count">(%s)</span>',  'Retired <span class="count">(%s)</span>',  count( $retired_components ),  'buddypress' ), number_format_i18n( count( $retired_components  ) ) ); ?></a></li>
    185196    </ul>
    186197
     
    214225                    endif; ?>
    215226
    216                     <tr id="<?php echo $name; ?>" class="<?php echo $name . ' ' . $class; ?>">
     227                    <tr id="<?php echo esc_attr( $name ); ?>" class="<?php echo esc_attr( $name ) . ' ' . esc_attr( $class ); ?>">
    217228                        <th scope="row">
    218229
     
    265276 *
    266277 * @since BuddyPress (1.6)
    267  * @todo Use settings API
    268  * @global BuddyPress $bp
    269  * @return false On failure
     278 * @todo Use settings API when it supports saving network settings
     279 * @return If not time to save settings
    270280 */
    271281function bp_core_admin_components_settings_handler() {
    272     global $bp;
    273 
    274     if ( isset( $_POST['bp-admin-component-submit'] ) ) {
    275         if ( !check_admin_referer('bp-admin-component-setup') )
    276             return false;
    277 
    278         // Settings form submitted, now save the settings. First, set active components
    279         if ( isset( $_POST['bp_components'] ) ) {
    280             // Save settings and upgrade schema
    281             require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
    282             $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
    283             bp_core_install( $bp->active_components );
    284 
    285             bp_update_option( 'bp-active-components', $bp->active_components );
    286         }
    287 
    288         $base_url = bp_get_admin_url(  add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) );
    289 
    290         wp_redirect( $base_url );
    291     }
     282   
     283    // Bail if not saving settings
     284    if ( ! isset( $_POST['bp-admin-component-submit'] ) )
     285        return;
     286
     287    // Bail if nonce fails
     288    if ( ! check_admin_referer( 'bp-admin-component-setup' ) )
     289        return;
     290
     291    // Settings form submitted, now save the settings. First, set active components
     292    if ( isset( $_POST['bp_components'] ) ) {
     293
     294        // Load up BuddyPress
     295        $bp = buddypress();
     296
     297        // Save settings and upgrade schema
     298        require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
     299
     300        $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
     301
     302        bp_core_install( $bp->active_components );
     303
     304        bp_update_option( 'bp-active-components', $bp->active_components );
     305    }
     306
     307    // Where are we redirecting to?
     308    $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) );
     309
     310    // Redirect
     311    wp_redirect( $base_url );
    292312}
    293313add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
Note: See TracChangeset for help on using the changeset viewer.