Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2024 07:41:30 PM (2 years 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-optouts.php

    r13818 r13886  
    2020 * @since 8.0.0
    2121 *
    22  * @global $bp_optouts_list_table
     22 * @global $bp_optouts_list_table BP_Optouts_List_Table List table instance for nonmember opt-outs admin page.
    2323 */
    2424function bp_core_optouts_admin_load() {
     
    2626
    2727        // Build redirection URL.
    28         $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
    29         $doaction    = bp_admin_list_table_current_bulk_action();
     28        $redirect_to = remove_query_arg(
     29                array(
     30                        'action',
     31                        'error',
     32                        'updated',
     33                        'activated',
     34                        'notactivated',
     35                        'deleted',
     36                        'notdeleted',
     37                        'resent',
     38                        'notresent',
     39                        'do_delete',
     40                        'do_resend',
     41                        'do_activate',
     42                        '_wpnonce',
     43                        'signup_ids',
     44                ),
     45                $_SERVER['REQUEST_URI']
     46        );
     47
     48        $doaction = bp_admin_list_table_current_bulk_action();
    3049
    3150        /**
     
    4665         * @param array $value Array of allowed actions to use.
    4766         */
    48         $allowed_actions = apply_filters( 'bp_optouts_admin_allowed_actions', array( 'do_delete',  'do_resend' ) );
    49 
    50         if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) {
    51 
    52                 require_once( ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php' );
     67        $allowed_actions = apply_filters( 'bp_optouts_admin_allowed_actions', array( 'do_delete', 'do_resend' ) );
     68
     69        if ( ! in_array( $doaction, $allowed_actions, true ) || ( -1 === $doaction ) ) {
     70
     71                require_once ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php';
    5372                $bp_optouts_list_table = new BP_Optouts_List_Table();
    5473
     
    101120
    102121        } else {
    103                 if ( empty( $_REQUEST['optout_ids' ] ) ) {
     122                if ( empty( $_REQUEST['optout_ids'] ) ) {
    104123                        return;
    105124                }
    106                 $optout_ids = wp_parse_id_list( $_REQUEST['optout_ids' ] );
     125                $optout_ids = wp_parse_id_list( $_REQUEST['optout_ids'] );
    107126
    108127                // Handle optout deletion.
    109                 if ( 'do_delete' == $doaction ) {
     128                if ( 'do_delete' === $doaction ) {
    110129
    111130                        // Nonce check.
     
    115134                        foreach ( $optout_ids as $optout_id ) {
    116135                                if ( bp_delete_optout_by_id( $optout_id ) ) {
    117                                         $success++;
     136                                        ++$success;
    118137                                }
    119138                        }
     
    134153                        bp_core_redirect( $redirect_to );
    135154
    136                 // Plugins can update other stuff from here.
     155                        // Plugins can update other stuff from here.
    137156                } else {
    138157
     
    153172        }
    154173}
    155 add_action( "load-tools_page_bp-optouts", 'bp_core_optouts_admin_load' );
     174add_action( 'load-tools_page_bp-optouts', 'bp_core_optouts_admin_load' );
    156175
    157176/**
     
    171190                $notice = array(
    172191                        'class'   => 'updated',
    173                         'message' => ''
     192                        'message' => '',
    174193                );
    175194
     
    177196                        $deleted            = absint( $_REQUEST['deleted'] );
    178197                        $notice['message'] .= sprintf(
     198                                /* translators: %s: number of deleted optouts */
    179199                                _nx(
    180                                         /* translators: %s: number of deleted optouts */
    181                                         '%s opt-out successfully deleted!', '%s opt-outs successfully deleted!',
     200                                        '%s opt-out successfully deleted!',
     201                                        '%s opt-outs successfully deleted!',
    182202                                        $deleted,
    183203                                        'nonmembers opt-out deleted',
     
    191211                        $notdeleted         = absint( $_REQUEST['notdeleted'] );
    192212                        $notice['message'] .= sprintf(
     213                                /* translators: %s: number of optouts that failed to be deleted */
    193214                                _nx(
    194                                         /* translators: %s: number of optouts that failed to be deleted */
    195                                         '%s opt-out was not deleted.', '%s opt-outs were not deleted.',
     215                                        '%s opt-out was not deleted.',
     216                                        '%s opt-outs were not deleted.',
    196217                                        $notdeleted,
    197218                                        'nonmembers opt-out not deleted',
     
    241262                        <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible">
    242263
    243                 <?php else: ?>
     264                <?php else : ?>
    244265
    245266                        <div class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible">
     
    250271                </div>
    251272
    252         <?php endif;
     273                <?php
     274        endif;
    253275
    254276        // Show the proper screen.
    255277        switch ( $doaction ) {
    256                 case 'delete' :
     278                case 'delete':
    257279                        bp_core_optouts_admin_manage( $doaction );
    258280                        break;
     
    270292 *
    271293 * @global $plugin_page
    272  * @global $bp_optouts_list_table
     294 * @global $bp_optouts_list_table BP_Optouts_List_Table List table instance for nonmember opt-outs admin page.
    273295 */
    274296function bp_core_optouts_admin_index() {
     
    312334                        'action2',
    313335                        '_wpnonce',
    314                         'optout_ids'
     336                        'optout_ids',
    315337                ),
    316338                $_SERVER['REQUEST_URI']
     
    341363                <?php $bp_optouts_list_table->views(); ?>
    342364
    343                 <form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">
     365                <form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ); ?>">
    344366                        <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
    345367                        <?php $bp_optouts_list_table->search_box( esc_html__( 'Search for a specific email address', 'buddypress' ), 'bp-optouts' ); ?>
    346368                </form>
    347369
    348                 <form id="bp-optouts-form" action="<?php echo esc_url( $form_url );?>" method="post">
     370                <form id="bp-optouts-form" action="<?php echo esc_url( $form_url ); ?>" method="post">
    349371                        <?php $bp_optouts_list_table->display(); ?>
    350372                </form>
    351373        </div>
    352 <?php
     374        <?php
    353375}
    354376
     
    381403
    382404        // Query for matching optouts, and filter out bad IDs.
    383         $args = array(
    384                 'id'     => $ids,
     405        $args       = array(
     406                'id' => $ids,
    385407        );
    386408        $optouts    = bp_get_optouts( $args );
     
    389411        // Check optout IDs and set up strings.
    390412        switch ( $action ) {
    391                 case 'delete' :
     413                case 'delete':
    392414                        if ( 0 === count( $optouts ) ) {
    393415                                $helper_text = __( 'No opt-out requests were found.', 'buddypress' );
     
    404426        $action_args = array(
    405427                'action'     => 'do_' . $action,
    406                 'optout_ids' => implode( ',', $optout_ids )
     428                'optout_ids' => implode( ',', $optout_ids ),
    407429        );
    408430
     
    430452
    431453                <ol class="bp-optouts-list">
    432                 <?php foreach ( $optouts as $optout ) : ?>
     454                <?php foreach ( $optouts as $optout ) : ?>
    433455
    434456                        <li>
    435                                 <strong><?php echo esc_html( $optout->email_address ) ?></strong>
     457                                <strong><?php echo esc_html( $optout->email_address ); ?></strong>
    436458                                <p class="description">
    437459                                        <?php
    438460                                        $last_modified = mysql2date( 'Y/m/d g:i:s a', $optout->date_modified );
    439461                                        /* translators: %s: modification date */
    440                                         printf( esc_html__( 'Date modified: %s', 'buddypress'), esc_html( $last_modified ) );
     462                                        printf( esc_html__( 'Date modified: %s', 'buddypress' ), esc_html( $last_modified ) );
    441463                                        ?>
    442464                                </p>
     
    448470                <?php if ( 'delete' === $action && count( $optouts ) ) : ?>
    449471
    450                         <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
    451 
    452                 <?php endif ; ?>
     472                        <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ); ?></strong></p>
     473
     474                <?php endif; ?>
    453475
    454476                <?php if ( count( $optouts ) ) : ?>
     
    458480                <?php endif; ?>
    459481
    460                 <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a>
     482                <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></a>
    461483        </div>
    462484
Note: See TracChangeset for help on using the changeset viewer.