213 | | // Settings form submitted, now save the settings. First, set active components |
| 220 | // Check to see which components have just been disabled or enabled |
| 221 | // We do this first so we'll still have access to old component settings data |
| 222 | $previous_components = get_site_option( 'bp-active-components' ) ? get_site_option( 'bp-active-components' ) : array(); |
| 223 | $new_components = isset( $_POST['bp_components'] ) ? $_POST['bp_components'] : array(); |
| 224 | |
| 225 | $activated = array_diff_assoc( $new_components, $previous_components ); |
| 226 | $deactivated = array_diff_assoc( $previous_components, $new_components ); |
| 227 | |
| 228 | // Create the query arguments. |
| 229 | // Translated component names are available now only for deactivated components |
| 230 | $deactivated_names = array(); |
| 231 | foreach ( $deactivated as $component_id => $a ) { |
| 232 | if ( !empty( $bp->{$component_id}->name ) ) |
| 233 | $deactivated_names[] = $bp->{$component_id}->name; |
| 234 | } |
| 235 | $deactivated_qs = urlencode( implode( ',', $deactivated_names ) ); |
| 236 | |
| 237 | // We'll get the activated component names after the redirect |
| 238 | $activated_qs = urlencode( implode( ',', array_keys( $activated ) ) ); |
| 239 | |
| 240 | // Now save the settings. First, set active components |
230 | | wp_redirect( network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) ) ); |
| 257 | $redirect = network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) ); |
| 258 | |
| 259 | if ( $activated_qs ) |
| 260 | $redirect = add_query_arg( array( 'activated' => $activated_qs ), $redirect ); |
| 261 | |
| 262 | if ( $deactivated_qs ) |
| 263 | $redirect = add_query_arg( array( 'deactivated' => $deactivated_qs ), $redirect ); |
| 264 | |
| 265 | wp_redirect( $redirect ); |
| 278 | global $bp; |
| 279 | |
| 280 | if ( isset( $_GET['activated'] ) ) { |
| 281 | $activated_component_ids = explode( ',', urldecode( $_GET['activated'] ) ); |
| 282 | |
| 283 | // Translated component names for activated components are only available now, |
| 284 | // after activation |
| 285 | $activated_components = array(); |
| 286 | foreach ( $activated_component_ids as $component_id ) { |
| 287 | if ( !empty( $bp->{$component_id}->name ) ) |
| 288 | $activated_components[] = $bp->{$component_id}->name; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | if ( isset( $_GET['deactivated'] ) ) { |
| 293 | // Deactivated component names have already come through the query string |
| 294 | $deactivated_components = explode( ',', urldecode( $_GET['deactivated'] ) ); |
| 295 | } |
255 | | <p><?php _e( 'Settings Saved', 'buddypress' ); ?></p> |
| 308 | <p><?php _e( 'Settings saved.', 'buddypress' ); ?></p> |
| 309 | |
| 310 | <?php if ( !empty( $activated_components ) ) : ?> |
| 311 | <p><?php printf( __( '<strong>Newly activated components:</strong> You have just activated the following components: <em>%1$s</em>. Finish setting them up under Directory Pages below. Note: you may need to <a href="%2$s">create a page for each newly activated component</a>, and then return to this screen to complete setup.', 'buddypress' ), implode( ', ', $activated_components ), admin_url( 'post-new.php?post_type=page' ) ) ?></p> |
| 312 | <?php endif ?> |
| 313 | |
| 314 | <?php if ( !empty( $deactivated_components ) ) : ?> |
| 315 | <p><?php printf( __( '<strong>Newly deactivated components:</strong> You have just deactivated the following components: <em>%1$s</em>. You may want to <a href="%2$s">delete or unpublish the old, unused directory pages</a>, so that they don\'t clutter your navigation.', 'buddypress' ), implode( ', ', $deactivated_components ), admin_url( 'edit.php?post_type=page' ) ) ?></p> |
| 316 | <?php endif ?> |