Changeset 6581 for trunk/bp-core/admin/bp-core-components.php
- Timestamp:
- 12/10/2012 08:25:00 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-components.php
r6558 r6581 50 50 function bp_core_admin_components_options() { 51 51 52 // Load core functions, if needed53 if ( !function_exists( 'bp_get_option' ) )54 require( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );55 56 52 // Declare local variables 57 53 $deactivated_components = array(); … … 78 74 ); 79 75 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 80 82 // Optional core components 81 83 $optional_components = array( … … 105 107 ), 106 108 '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' ) 109 111 ), 110 112 'blogs' => array( … … 114 116 ); 115 117 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 116 123 // Add blogs tracking if multisite 117 124 if ( is_multisite() ) { … … 130 137 // Trim off namespace and filename 131 138 $trimmed = array(); 132 foreach ( (array) $deactivated_components as $component => $value) {139 foreach ( array_keys( (array) $deactivated_components ) as $component ) { 133 140 $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) ); 134 141 } 135 142 136 143 // 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 ) { 138 145 if ( !in_array( $ocomponent, $trimmed ) ) { 139 146 $active_components[$ocomponent] = 1; … … 176 183 $current_components = $required_components; 177 184 break; 185 case 'retired' : 186 $current_components = $retired_components; 187 break; 178 188 } ?> 179 189 … … 182 192 <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> 183 193 <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> 185 196 </ul> 186 197 … … 214 225 endif; ?> 215 226 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 ); ?>"> 217 228 <th scope="row"> 218 229 … … 265 276 * 266 277 * @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 270 280 */ 271 281 function 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 ); 292 312 } 293 313 add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
Note: See TracChangeset
for help on using the changeset viewer.