Skip to:
Content

BuddyPress.org

Changeset 13881


Ignore:
Timestamp:
06/01/2024 04:36:50 PM (6 months ago)
Author:
espellcaste
Message:

WPCS: miscellaneous fixes for the src/bp-core/admin/bp-core-admin-components.php template.

See #7228 and #9164

File:
1 edited

Legend:

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

    r13818 r13881  
    1515 *
    1616 * @since 1.6.0
    17  *
    1817 */
    1918function bp_core_admin_components_settings() {
     
    2827
    2928            <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' ); ?>"/>
    3130            </p>
    3231
     
    3635    </div>
    3736
    38 <?php
     37    <?php
    3938}
    4039
     
    5857     * @param mixed $value Active components.
    5958     */
    60     $active_components      = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
     59    $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    6160
    6261    // The default components (if none are previously selected).
    6362    $default_components = array(
    64         'xprofile' => array(
     63        'xprofile'      => array(
    6564            '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(
    6968            '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' ),
    7170        ),
    7271        'notifications' => array(
    7372            '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' ),
    7574        ),
    7675    );
     
    7877    $optional_components = bp_core_admin_get_components( 'optional' );
    7978    $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' );
    8180
    8281    // Merge optional and required together.
     
    8786    if ( empty( $active_components ) ) {
    8887        $deactivated_components = bp_get_option( 'bp-deactivated-components' );
    89         if ( !empty( $deactivated_components ) ) {
     88        if ( ! empty( $deactivated_components ) ) {
    9089
    9190            // Trim off namespace and filename.
     
    9796            // Loop through the optional components to create an active component array.
    9897            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;
    101100                }
    102101            }
     
    111110    // Core component is always active.
    112111    $active_components['core'] = $all_components['core'];
    113     $inactive_components       = array_diff( array_keys( $all_components ) , array_keys( $active_components ) );
     112    $inactive_components       = array_diff( array_keys( $all_components ), array_keys( $active_components ) );
    114113
    115114    /** Display **************************************************************
     
    118117    // Get the total count of all plugins.
    119118    $all_count = count( $all_components );
    120     $page      = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    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':
    125124            $current_components = $all_components;
    126125            break;
    127         case 'active' :
     126        case 'active':
    128127            foreach ( array_keys( $active_components ) as $component ) {
    129                 $current_components[$component] = $all_components[$component];
     128                $current_components[ $component ] = $all_components[ $component ];
    130129            }
    131130            break;
    132         case 'inactive' :
     131        case 'inactive':
    133132            foreach ( $inactive_components as $component ) {
    134                 $current_components[$component] = $all_components[$component];
     133                $current_components[ $component ] = $all_components[ $component ];
    135134            }
    136135            break;
    137         case 'mustuse' :
     136        case 'mustuse':
    138137            $current_components = $required_components;
    139138            break;
    140         case 'retired' :
     139        case 'retired':
    141140            $current_components = $retired_components;
    142141            break;
     
    180179            'view'   => sprintf(
    181180                /* 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' ),
    183182                number_format_i18n( count( $retired_components ) )
    184183            ),
     
    197196        <?php foreach ( $component_views as $component_view ) : ?>
    198197            <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; ?>>
    200215                    <?php echo wp_kses( $component_view['view'], array( 'span' => array( 'class' => true ) ) ); ?>
    201216                </a><?php echo 'retired' !== $component_view['action'] ? ' |' : ''; ?>
    202217            </li>
    203         <?php endforeach ;?>
     218        <?php endforeach; ?>
    204219    </ul>
    205220
     
    234249
    235250                    <?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';
    238253                    } else {
    239254                        $class = 'active';
     
    244259                        <th scope="row" class="check-column">
    245260
    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">
    250270                                    <?php
    251271                                        /* translators: accessibility text */
     
    258278                        </th>
    259279                        <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 ]" ); ?>">
    261281                                <span aria-hidden="true"></span>
    262282                                <strong><?php echo esc_html( $labels['title'] ); ?></strong>
     
    347367
    348368        // 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'] );
    353373        $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
    354374
     
    409429    $current_action = 'all';
    410430
    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 ) ) {
    412432        $current_action = $_GET['action'];
    413433    }
     
    416436
    417437    switch ( $current_action ) {
    418         case 'retired' :
     438        case 'retired':
    419439            $retired_components = bp_core_admin_get_components( 'retired' );
    420440            foreach ( array_keys( $retired_components ) as $retired_component ) {
     
    424444            } // Fall through.
    425445
    426 
    427         case 'inactive' :
     446        case 'inactive':
    428447            $components = array_merge( $submitted, $current_components );
    429448            break;
    430449
    431         case 'all' :
    432         case 'active' :
    433         default :
     450        case 'all':
     451        case 'active':
     452        default:
    434453            $components = $submitted;
    435454            break;
     
    447466 * @since 1.7.0
    448467 *
    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'.
    450470 * @return array Requested components' data.
    451471 */
     
    461481     * @param string $type       Type of component list requested.
    462482     *                           Possible values include 'all', 'optional',
    463      *                           'retired', 'required'.
     483     *                           'retired', and 'required'.
    464484     */
    465485    return apply_filters( 'bp_core_admin_get_components', $components, $type );
Note: See TracChangeset for help on using the changeset viewer.