Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2024 07:41:30 PM (10 months ago)
Author:
espellcaste
Message:

WPCS: Part II: miscellaneous fixes for some of the files of the core component.

Follow-up to 13883.

See #9164 and #7228

File:
1 edited

Legend:

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

    r13878 r13886  
    1414 * Main settings section description for the settings page.
    1515 *
    16  * @since 1.6.0
    17  */
    18 function bp_admin_setting_callback_main_section() { }
     16 * @internal This function is used as a callback for the 'bp_main_section' settings section.
     17 *
     18 * @since 1.6.0
     19 */
     20function bp_admin_setting_callback_main_section() {}
    1921
    2022/**
     
    2224 *
    2325 * @since 1.6.0
    24  *
    2526 */
    2627function bp_admin_setting_callback_admin_bar() {
    27 ?>
    28 
    29     <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( !bp_hide_loggedout_adminbar( false ) ); ?> />
     28    ?>
     29
     30    <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( ! bp_hide_loggedout_adminbar( false ) ); ?> />
    3031    <label for="hide-loggedout-adminbar"><?php esc_html_e( 'Show the Toolbar for logged out users', 'buddypress' ); ?></label>
    3132
    32 <?php
     33    <?php
    3334}
    3435
     
    4041function bp_admin_setting_callback_community_visibility() {
    4142    $visibility = bp_get_community_visibility( 'all' );
    42 ?>
     43    ?>
    4344    <select name="_bp_community_visibility[global]" id="_bp_community_visibility-global" aria-describedby="_bp_community_visibility_description" autocomplete="off">
    4445        <option value="anyone" <?php echo selected( $visibility['global'], 'anyone' ); ?>><?php esc_html_e( 'Anyone', 'buddypress' ); ?></option>
     
    4748
    4849    <p id="_bp_community_visibility_description" class="description"><?php esc_html_e( 'Choose "Anyone" to allow any visitor access to your community area. Choose "Members Only" to restrict access to your community area to logged-in members only.', 'buddypress' ); ?></p>
    49 <?php
     50    <?php
    5051}
    5152
     
    5657 *
    5758 * @param mixed $saved_value The value passed to the save function.
     59 * @return array
    5860 */
    5961function bp_admin_sanitize_callback_community_visibility( $saved_value ) {
     
    9193 */
    9294function bp_admin_setting_callback_theme_package_id() {
    93     $options = '';
     95    $options    = '';
     96    $package_id = bp_get_theme_package_id();
    9497
    9598    /*
     
    104107            '<option value="%1$s" %2$s>%3$s</option>',
    105108            esc_attr( $id ),
    106             selected( $theme->id, bp_get_theme_package_id(), false ),
     109            selected( $theme->id, $package_id, false ),
    107110            esc_html( $theme->name )
    108111        );
     
    110113
    111114    // phpcs:disable WordPress.Security.EscapeOutput
    112     if ( $options ) : ?>
     115    if ( $options ) :
     116        ?>
    113117        <select name="_bp_theme_package_id" id="_bp_theme_package_id" aria-describedby="_bp_theme_package_description"><?php echo $options; ?></select>
    114118        <p id="_bp_theme_package_description" class="description"><?php esc_html_e( 'The selected Template Pack will serve all BuddyPress templates.', 'buddypress' ); ?></p>
     
    117121        <p><?php esc_html_e( 'No template packages available.', 'buddypress' ); ?></p>
    118122
    119     <?php endif;
     123        <?php
     124    endif;
    120125    // phpcs:enable
    121126}
     
    126131 * Groups settings section description for the settings page.
    127132 *
    128  * @since 1.6.0
    129  */
    130 function bp_admin_setting_callback_activity_section() { }
     133 * @internal This function is used as a callback for the 'bp_activity_section' settings section.
     134 *
     135 * @since 1.6.0
     136 */
     137function bp_admin_setting_callback_activity_section() {}
    131138
    132139/**
     
    134141 *
    135142 * @since 1.6.0
    136  *
    137143 */
    138144function bp_admin_setting_callback_activity_akismet() {
    139 ?>
    140 
     145    ?>
    141146    <input id="_bp_enable_akismet" name="_bp_enable_akismet" type="checkbox" value="1" <?php checked( bp_is_akismet_active( true ) ); ?> />
    142147    <label for="_bp_enable_akismet"><?php esc_html_e( 'Allow Akismet to scan for activity stream spam', 'buddypress' ); ?></label>
    143 
    144 <?php
     148    <?php
    145149}
    146150
     
    152156function bp_admin_setting_callback_blogforum_comments() {
    153157    $support = post_type_supports( 'post', 'buddypress-activity' );
    154 ?>
     158    ?>
    155159
    156160    <input id="bp-disable-blogforum-comments" name="bp-disable-blogforum-comments" type="checkbox" value="1" <?php checked( ! bp_disable_blogforum_comments( false ) ); ?> <?php disabled( ! $support ); ?> />
     
    160164    <?php endif; ?>
    161165
    162 <?php
     166    <?php
    163167}
    164168
     
    169173 */
    170174function bp_admin_setting_callback_heartbeat() {
    171 ?>
    172 
     175    ?>
    173176    <input id="_bp_enable_heartbeat_refresh" name="_bp_enable_heartbeat_refresh" type="checkbox" value="1" <?php checked( bp_is_activity_heartbeat_active( true ) ); ?> />
    174177    <label for="_bp_enable_heartbeat_refresh"><?php esc_html_e( 'Automatically check for new items while viewing the activity stream', 'buddypress' ); ?></label>
    175 
    176 <?php
     178    <?php
    177179}
    178180
     
    187189 *
    188190 * @param bool $value Whether or not to sanitize.
    189  * @return bool
     191 * @return int
    190192 */
    191193function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
     
    198200 * Profile settings section description for the settings page.
    199201 *
    200  * @since 1.6.0
    201  */
    202 function bp_admin_setting_callback_members_section() { }
     202 * @internal This function is used as a callback for the 'bp_members_section' settings section.
     203 *
     204 * @since 1.6.0
     205 */
     206function bp_admin_setting_callback_members_section() {}
    203207
    204208/**
     
    209213 */
    210214function bp_admin_setting_callback_avatar_uploads() {
    211 ?>
     215    ?>
    212216    <input id="bp-disable-avatar-uploads" name="bp-disable-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_avatar_uploads( false ) ); ?> />
    213217    <label for="bp-disable-avatar-uploads"><?php esc_html_e( 'Allow registered members to upload avatars', 'buddypress' ); ?></label>
    214 <?php
     218    <?php
    215219}
    216220
     
    222226 */
    223227function bp_admin_setting_callback_cover_image_uploads() {
    224 ?>
     228    ?>
    225229    <input id="bp-disable-cover-image-uploads" name="bp-disable-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_cover_image_uploads() ); ?> />
    226230    <label for="bp-disable-cover-image-uploads"><?php esc_html_e( 'Allow registered members to upload cover images', 'buddypress' ); ?></label>
    227 <?php
     231    <?php
    228232}
    229233
     
    234238 */
    235239function bp_admin_setting_callback_members_invitations() {
    236 ?>
     240    ?>
    237241    <input id="bp-enable-members-invitations" name="bp-enable-members-invitations" type="checkbox" value="1" <?php checked( bp_get_members_invitations_allowed() ); ?> />
    238242    <label for="bp-enable-members-invitations"><?php esc_html_e( 'Allow registered members to invite people to join this network', 'buddypress' ); ?></label>
     
    255259 */
    256260function bp_admin_setting_callback_membership_requests() {
    257 ?>
     261    ?>
    258262    <input id="bp-enable-membership-requests" name="bp-enable-membership-requests" type="checkbox" value="1" <?php checked( bp_get_membership_requests_required( 'raw' ) ); ?> <?php disabled( bp_get_signup_allowed() ); ?> />
    259263    <label for="bp-enable-membership-requests"><?php esc_html_e( 'Allow visitors to request site membership. If enabled, an administrator must approve each new site membership request.', 'buddypress' ); ?></label>
     
    262266            <p class="description"><?php esc_html_e( 'With a WP multisite setup, to require membership requests for new signups, choose one of the following two options from the Network Settings > Registration Settings pane:', 'buddypress' ); ?><p>
    263267                <ul>
    264                     <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests but not allow site creation requests, select "Registration is disabled".', 'buddypress' ) ?></p></li>
    265                     <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests and to allow new sites to be created by your users, choose "Logged in users may register new sites".', 'buddypress' ) ?></p></li>
     268                    <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests but not allow site creation requests, select "Registration is disabled".', 'buddypress' ); ?></p></li>
     269                    <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests and to allow new sites to be created by your users, choose "Logged in users may register new sites".', 'buddypress' ); ?></p></li>
    266270                </ul>
    267271            <p class="description"><?php esc_html_e( 'The other two options, "User accounts may be registered" and "Both sites and user accounts can be registered," are open in nature and membership requests will not be enabled if one of those options is selected.', 'buddypress' ); ?><p>
     
    284288 * Profile settings section description for the settings page.
    285289 *
    286  * @since 1.6.0
    287  */
    288 function bp_admin_setting_callback_xprofile_section() { }
     290 * @internal This function is used as a callback for the 'bp_xprofile_section' settings section.
     291 *
     292 * @since 1.6.0
     293 */
     294function bp_admin_setting_callback_xprofile_section() {}
    289295
    290296/**
     
    292298 *
    293299 * @since 1.6.0
    294  *
    295300 */
    296301function bp_admin_setting_callback_profile_sync() {
    297 ?>
    298 
    299     <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( !bp_disable_profile_sync( false ) ); ?> />
     302    ?>
     303    <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( ! bp_disable_profile_sync( false ) ); ?> />
    300304    <label for="bp-disable-profile-sync"><?php esc_html_e( 'Enable BuddyPress to WordPress profile syncing', 'buddypress' ); ?></label>
    301 
    302 <?php
     305    <?php
    303306}
    304307
     
    308311 * Groups settings section description for the settings page.
    309312 *
    310  * @since 1.6.0
    311  */
    312 function bp_admin_setting_callback_groups_section() { }
     313 * @internal This function is used as a callback for the 'bp_groups_section' settings section.
     314 *
     315 * @since 1.6.0
     316 */
     317function bp_admin_setting_callback_groups_section() {}
    313318
    314319/**
     
    316321 *
    317322 * @since 1.6.0
    318  *
    319323 */
    320324function bp_admin_setting_callback_group_creation() {
    321 ?>
    322 
    323     <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox" aria-describedby="bp_group_creation_description" value="1" <?php checked( !bp_restrict_group_creation( false ) ); ?> />
     325    ?>
     326    <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox" aria-describedby="bp_group_creation_description" value="1" <?php checked( ! bp_restrict_group_creation( false ) ); ?> />
    324327    <label for="bp_restrict_group_creation"><?php esc_html_e( 'Enable group creation for all users', 'buddypress' ); ?></label>
    325328    <p class="description" id="bp_group_creation_description"><?php esc_html_e( 'Administrators can always create groups, regardless of this setting.', 'buddypress' ); ?></p>
    326 
    327 <?php
     329    <?php
    328330}
    329331
     
    334336 */
    335337function bp_admin_setting_callback_group_avatar_uploads() {
    336 ?>
     338    ?>
    337339    <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> />
    338340    <label for="bp-disable-group-avatar-uploads"><?php esc_html_e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label>
    339 <?php
     341    <?php
    340342}
    341343
     
    346348 */
    347349function bp_admin_setting_callback_group_cover_image_uploads() {
    348 ?>
     350    ?>
    349351    <input id="bp-disable-group-cover-image-uploads" name="bp-disable-group-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_cover_image_uploads() ); ?> />
    350352    <label for="bp-disable-group-cover-image-uploads"><?php esc_html_e( 'Allow customizable cover images for groups', 'buddypress' ); ?></label>
    351 <?php
     353    <?php
    352354}
    353355
     
    358360 */
    359361function bp_admin_setting_callback_group_activity_deletions() {
    360 ?>
     362    ?>
    361363    <input id="bp-disable-group-activity-deletions" name="bp-disable-group-activity-deletions" type="checkbox" value="1" <?php checked( ! bp_disable_group_activity_deletions() ); ?> />
    362364    <label for="bp-disable-group-activity-deletions"><?php esc_html_e( "Allow group administrators and moderators to delete activity items from their group's activity stream", 'buddypress' ); ?></label>
    363 <?php
     365    <?php
    364366}
    365367
     
    369371 * Account settings section description for the settings page.
    370372 *
     373 * @internal This function is used as a callback for the 'bp_account_section' settings section.
     374 *
    371375 * @since 12.0.0
    372376 */
    373 function bp_admin_setting_callback_settings_section() { }
     377function bp_admin_setting_callback_settings_section() {}
    374378
    375379/**
     
    379383 */
    380384function bp_admin_setting_callback_account_deletion() {
    381 ?>
    382 
     385    ?>
    383386    <input id="bp-disable-account-deletion" name="bp-disable-account-deletion" type="checkbox" value="1" <?php checked( ! bp_disable_account_deletion( false ) ); ?> />
    384387    <label for="bp-disable-account-deletion"><?php esc_html_e( 'Allow registered members to delete their own accounts', 'buddypress' ); ?></label>
    385 
    386 <?php
     388    <?php
    387389}
    388390
     
    393395 *
    394396 * @since 1.6.0
    395  *
    396397 */
    397398function bp_core_admin_settings() {
     
    403404
    404405    <div class="buddypress-body">
    405         <form action="<?php echo esc_url( $form_action ) ?>" method="post">
     406        <form action="<?php echo esc_url( $form_action ); ?>" method="post">
    406407
    407408            <?php settings_fields( 'buddypress' ); ?>
     
    415416    </div>
    416417
    417 <?php
     418    <?php
    418419}
    419420
     
    426427    global $wp_settings_fields;
    427428
    428     if ( isset( $_GET['page'] ) && 'bp-settings' == $_GET['page'] && !empty( $_POST['submit'] ) ) {
     429    if ( isset( $_GET['page'] ) && 'bp-settings' === $_GET['page'] && ! empty( $_POST['submit'] ) ) {
    429430        check_admin_referer( 'buddypress-options' );
    430431
     
    434435            foreach ( (array) $wp_settings_fields['buddypress'] as $section => $settings ) {
    435436                foreach ( $settings as $setting_name => $setting ) {
    436                     $value = isset( $_POST[$setting_name] ) ? $_POST[$setting_name] : '';
     437                    $value = isset( $_POST[ $setting_name ] ) ? $_POST[ $setting_name ] : '';
    437438
    438439                    bp_update_option( $setting_name, $value );
     
    459460            // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked,
    460461            // the corresponding option should be unset.
    461             $value = isset( $_POST[$legacy_option] ) ? '' : 1;
     462            $value = isset( $_POST[ $legacy_option ] ) ? '' : 1;
    462463            bp_update_option( $legacy_option, $value );
    463464        }
    464465
    465         bp_core_redirect( add_query_arg( array( 'page' => 'bp-settings', 'updated' => 'true' ), bp_get_admin_url( 'admin.php' ) ) );
     466        bp_core_redirect(
     467            add_query_arg(
     468                array(
     469                    'page'    => 'bp-settings',
     470                    'updated' => 'true',
     471                ),
     472                bp_get_admin_url( 'admin.php' )
     473            )
     474        );
    466475    }
    467476}
     
    473482 * @since 1.6.0
    474483 *
    475  * @param string $option  Form option to echo.
    476  * @param string $default Form option default.
    477  * @param bool   $slug    Form option slug.
    478  */
    479 function bp_form_option( $option, $default = '' , $slug = false ) {
     484 * @param string $option         Form option to echo.
     485 * @param string $default_option Form option default.
     486 * @param bool   $slug           Form option slug.
     487 */
     488function bp_form_option( $option, $default_option = '', $slug = false ) {
    480489    // phpcs:ignore WordPress.Security.EscapeOutput
    481     echo bp_get_form_option( $option, $default, $slug );
    482 }
    483 
    484 /**
    485  * Return settings API option
    486  *
    487  * @since 1.6.0
    488  *
    489  *
    490  * @param string $option  Form option to return.
    491  * @param string $default Form option default.
    492  * @param bool   $slug    Form option slug.
     490    echo bp_get_form_option( $option, $default_option, $slug );
     491}
     492
     493/**
     494 * Return settings API option.
     495 *
     496 * @since 1.6.0
     497 *
     498 * @param string $option         Form option to return.
     499 * @param string $default_option Optional. Form option default. Default is empty string.
     500 * @param bool   $slug           Optional. Form option slug. Default is false.
    493501 * @return string
    494502 */
    495 function bp_get_form_option( $option, $default = '', $slug = false ) {
     503function bp_get_form_option( $option, $default_option = '', $slug = false ) {
    496504
    497505    // Get the option and sanitize it.
    498     $value = bp_get_option( $option, $default );
     506    $value = bp_get_option( $option, $default_option );
    499507
    500508    // Slug?
    501509    if ( true === $slug ) {
    502 
    503510        /**
    504511         * Filters the slug value in the form field.
     
    507514         *
    508515         * @param string $value Value being returned for the requested option.
     516         * @param string $option Option whose value is being requested.
    509517         */
    510         $value = esc_attr( apply_filters( 'editable_slug', $value ) );
    511     } else { // Not a slug.
    512         $value = esc_attr( $value );
     518        $value = apply_filters( 'editable_slug', $value, $option );
    513519    }
    514520
    515521    // Fallback to default.
    516522    if ( empty( $value ) ) {
    517         $value = $default;
     523        $value = $default_option;
    518524    }
     525
     526    $value = esc_attr( $value );
    519527
    520528    /**
Note: See TracChangeset for help on using the changeset viewer.