Changeset 13881
- Timestamp:
- 06/01/2024 04:36:50 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-components.php
r13818 r13881 15 15 * 16 16 * @since 1.6.0 17 *18 17 */ 19 18 function bp_core_admin_components_settings() { … … 28 27 29 28 <p class="submit clear"> 30 <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php esc_attr_e( 'Save Settings', 'buddypress' ) ?>"/>29 <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php esc_attr_e( 'Save Settings', 'buddypress' ); ?>"/> 31 30 </p> 32 31 … … 36 35 </div> 37 36 38 <?php37 <?php 39 38 } 40 39 … … 58 57 * @param mixed $value Active components. 59 58 */ 60 $active_components 59 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); 61 60 62 61 // The default components (if none are previously selected). 63 62 $default_components = array( 64 'xprofile' => array(63 'xprofile' => array( 65 64 'title' => __( 'Extended Profiles', 'buddypress' ), 66 'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' ) 67 ), 68 'settings' => array(65 'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' ), 66 ), 67 'settings' => array( 69 68 'title' => __( 'Account Settings', 'buddypress' ), 70 'description' => __( 'Allow your users to modify their account and notification settings directly from within their profiles.', 'buddypress' ) 69 'description' => __( 'Allow your users to modify their account and notification settings directly from within their profiles.', 'buddypress' ), 71 70 ), 72 71 'notifications' => array( 73 72 'title' => __( 'Notifications', 'buddypress' ), 74 'description' => __( 'Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.', 'buddypress' ) 73 'description' => __( 'Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.', 'buddypress' ), 75 74 ), 76 75 ); … … 78 77 $optional_components = bp_core_admin_get_components( 'optional' ); 79 78 $required_components = bp_core_admin_get_components( 'required' ); 80 $retired_components = bp_core_admin_get_components( 'retired' 79 $retired_components = bp_core_admin_get_components( 'retired' ); 81 80 82 81 // Merge optional and required together. … … 87 86 if ( empty( $active_components ) ) { 88 87 $deactivated_components = bp_get_option( 'bp-deactivated-components' ); 89 if ( ! empty( $deactivated_components ) ) {88 if ( ! empty( $deactivated_components ) ) { 90 89 91 90 // Trim off namespace and filename. … … 97 96 // Loop through the optional components to create an active component array. 98 97 foreach ( array_keys( (array) $optional_components ) as $ocomponent ) { 99 if ( ! in_array( $ocomponent, $trimmed) ) {100 $active_components[ $ocomponent] = 1;98 if ( ! in_array( $ocomponent, $trimmed, true ) ) { 99 $active_components[ $ocomponent ] = 1; 101 100 } 102 101 } … … 111 110 // Core component is always active. 112 111 $active_components['core'] = $all_components['core']; 113 $inactive_components = array_diff( array_keys( $all_components ) 112 $inactive_components = array_diff( array_keys( $all_components ), array_keys( $active_components ) ); 114 113 115 114 /** Display ************************************************************** … … 118 117 // Get the total count of all plugins. 119 118 $all_count = count( $all_components ); 120 $page = bp_core_do_network_admin() 121 $action = ! empty( $_GET['action'] ) ? $_GET['action'] : 'all';122 123 switch ( $action ) {124 case 'all' 119 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 120 $action = ! empty( $_GET['action'] ) ? $_GET['action'] : 'all'; 121 122 switch ( $action ) { 123 case 'all': 125 124 $current_components = $all_components; 126 125 break; 127 case 'active' 126 case 'active': 128 127 foreach ( array_keys( $active_components ) as $component ) { 129 $current_components[ $component] = $all_components[$component];128 $current_components[ $component ] = $all_components[ $component ]; 130 129 } 131 130 break; 132 case 'inactive' 131 case 'inactive': 133 132 foreach ( $inactive_components as $component ) { 134 $current_components[ $component] = $all_components[$component];133 $current_components[ $component ] = $all_components[ $component ]; 135 134 } 136 135 break; 137 case 'mustuse' 136 case 'mustuse': 138 137 $current_components = $required_components; 139 138 break; 140 case 'retired' 139 case 'retired': 141 140 $current_components = $retired_components; 142 141 break; … … 180 179 'view' => sprintf( 181 180 /* translators: %s: the number of retired components */ 182 _n( 'Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>', count( $retired_components ),'buddypress' ),181 _n( 'Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>', count( $retired_components ), 'buddypress' ), 183 182 number_format_i18n( count( $retired_components ) ) 184 183 ), … … 197 196 <?php foreach ( $component_views as $component_view ) : ?> 198 197 <li> 199 <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => $component_view['action'] ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === $component_view['action'] ) : ?>class="current"<?php endif; ?>> 198 <a href=" 199 <?php 200 echo esc_url( 201 add_query_arg( 202 array( 203 'page' => 'bp-components', 204 'action' => $component_view['action'], 205 ), 206 bp_get_admin_url( $page ) 207 ) 208 ); 209 ?> 210 " 211 <?php 212 if ( $action === $component_view['action'] ) : 213 ?> 214 class="current"<?php endif; ?>> 200 215 <?php echo wp_kses( $component_view['view'], array( 'span' => array( 'class' => true ) ) ); ?> 201 216 </a><?php echo 'retired' !== $component_view['action'] ? ' |' : ''; ?> 202 217 </li> 203 <?php endforeach ;?>218 <?php endforeach; ?> 204 219 </ul> 205 220 … … 234 249 235 250 <?php 236 if ( ! in_array( $name, array( 'core', 'members' ) ) ) {237 $class = isset( $active_components[ esc_attr( $name )] ) ? 'active' : 'inactive';251 if ( ! in_array( $name, array( 'core', 'members' ), true ) ) { 252 $class = isset( $active_components[ esc_attr( $name ) ] ) ? 'active' : 'inactive'; 238 253 } else { 239 254 $class = 'active'; … … 244 259 <th scope="row" class="check-column"> 245 260 246 <?php if ( ! in_array( $name, array( 'core', 'members' ) ) ) : ?> 247 248 <input type="checkbox" id="<?php echo esc_attr( "bp_components[$name]" ); ?>" name="<?php echo esc_attr( "bp_components[$name]" ); ?>" value="1"<?php checked( isset( $active_components[esc_attr( $name )] ) ); ?> /> 249 <label for="<?php echo esc_attr( "bp_components[$name]" ); ?>" class="screen-reader-text"> 261 <?php if ( ! in_array( $name, array( 'core', 'members' ), true ) ) : ?> 262 263 <input 264 type="checkbox" 265 id="<?php echo esc_attr( "bp_components[ $name ]" ); ?>" 266 name="<?php echo esc_attr( "bp_components[ $name ]" ); ?>" 267 value="1"<?php checked( isset( $active_components[ esc_attr( $name ) ] ) ); ?> 268 /> 269 <label for="<?php echo esc_attr( "bp_components[ $name ]" ); ?>" class="screen-reader-text"> 250 270 <?php 251 271 /* translators: accessibility text */ … … 258 278 </th> 259 279 <td class="plugin-title column-primary"> 260 <label for="<?php echo esc_attr( "bp_components[ $name]" ); ?>">280 <label for="<?php echo esc_attr( "bp_components[ $name ]" ); ?>"> 261 281 <span aria-hidden="true"></span> 262 282 <strong><?php echo esc_html( $labels['title'] ); ?></strong> … … 347 367 348 368 // Save settings and upgrade schema. 349 require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );350 require_once ( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );351 352 $submitted = stripslashes_deep( $_POST['bp_components'] );369 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 370 require_once $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php'; 371 372 $submitted = stripslashes_deep( $_POST['bp_components'] ); 353 373 $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted ); 354 374 … … 409 429 $current_action = 'all'; 410 430 411 if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'active', 'inactive', 'retired' ) ) ) {431 if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'active', 'inactive', 'retired' ), true ) ) { 412 432 $current_action = $_GET['action']; 413 433 } … … 416 436 417 437 switch ( $current_action ) { 418 case 'retired' 438 case 'retired': 419 439 $retired_components = bp_core_admin_get_components( 'retired' ); 420 440 foreach ( array_keys( $retired_components ) as $retired_component ) { … … 424 444 } // Fall through. 425 445 426 427 case 'inactive' : 446 case 'inactive': 428 447 $components = array_merge( $submitted, $current_components ); 429 448 break; 430 449 431 case 'all' 432 case 'active' 433 default 450 case 'all': 451 case 'active': 452 default: 434 453 $components = $submitted; 435 454 break; … … 447 466 * @since 1.7.0 448 467 * 449 * @param string $type Optional; component type to fetch. Default value is 'all', or 'optional', 'retired', 'required'. 468 * @param string $type Optional; Component type to fetch. Defaults to 'all'. 469 * Possible values include 'all', 'optional', 'retired', and 'required'. 450 470 * @return array Requested components' data. 451 471 */ … … 461 481 * @param string $type Type of component list requested. 462 482 * Possible values include 'all', 'optional', 463 * 'retired', 'required'.483 * 'retired', and 'required'. 464 484 */ 465 485 return apply_filters( 'bp_core_admin_get_components', $components, $type );
Note: See TracChangeset
for help on using the changeset viewer.