Skip to:
Content

BuddyPress.org

Changeset 8438


Ignore:
Timestamp:
05/21/2014 12:11:51 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Clean-up in admin/bp-members-classes.php:

  • Use sprint() on URL's to remove hard-to-read concatenation
  • Audit use of get text functions (a few were incorrectly escaped, others incorrectly nesting other functions)
  • Fix inconsistencies between single-site and multi-site list tables
  • Code formatting, whitespace, etc...

Fixes #5654.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/admin/bp-members-classes.php

    r8272 r8438  
    5555                global $usersearch;
    5656
    57                 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    58 
     57                $usersearch       = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    5958                $signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
    60 
    61                 $paged = $this->get_pagenum();
     59                $paged            = $this->get_pagenum();
    6260
    6361                $args = array(
     
    10098                // Remove the 'current' class from the 'All' link
    10199                $views['all']        = str_replace( 'class="current"', '', $views['all'] );
    102                 $views['registered'] = '<a href="' . add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) . '"  class="current">' . sprintf( _x( 'Pending <span class="count">(%s)</span>', 'signup users', 'buddypress' ), number_format_i18n( $this->signup_counts ) ) . '</a>';
     100                $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
    103101
    104102                return $views;
     
    125123                return apply_filters( 'bp_members_signup_columns', array(
    126124                        'cb'         => '<input type="checkbox" />',
    127                         'username'   => __( 'Username', 'buddypress' ),
    128                         'name'       => __( 'Name', 'buddypress' ),
    129                         'email'      => __( 'Email', 'buddypress' ),
    130                         'registered' => __( 'Registered', 'buddypress' ),
    131                         'date_sent'  => __( 'Last Sent', 'buddypress' ),
    132                         'count_sent' => __( '# Times Emailed', 'buddypress' )
     125                        'username'   => __( 'Username',    'buddypress' ),
     126                        'name'       => __( 'Name',        'buddypress' ),
     127                        'email'      => __( 'Email',       'buddypress' ),
     128                        'registered' => __( 'Registered',  'buddypress' ),
     129                        'date_sent'  => __( 'Last Sent',   'buddypress' ),
     130                        'count_sent' => __( 'Emails Sent', 'buddypress' )
    133131                ) );
    134132        }
     
    142140                $actions = array(
    143141                        'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
    144                         'resend'   => _x( 'Email', 'Pending signup action', 'buddypress' ),
     142                        'resend'   => _x( 'Email',    'Pending signup action', 'buddypress' ),
    145143                );
    146144
     
    168166                        // Specific case when BuddyPress is not network activated
    169167                        if ( is_multisite() && current_user_can( 'manage_network_users') ) {
    170                                 $link = '<a href="' . esc_url( network_admin_url( 'settings.php' ) ) . '">' . esc_html__( 'Edit settings', 'buddypress' ) . '</a>';
     168                                $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php'       ) ), esc_html__( 'Edit settings', 'buddypress' ) );
    171169                        } elseif ( current_user_can( 'manage_options' ) ) {
    172                                 $link = '<a href="' . esc_url( bp_get_admin_url( 'options-general.php' ) ) . '">' . esc_html__( 'Edit settings', 'buddypress' ) . '</a>';
     170                                $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( bp_get_admin_url( 'options-general.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) );
    173171                        }
    174                        
     172
    175173                        printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
    176174                }
    177                        
     175
    178176        }
    179177
     
    223221         */
    224222        public function column_cb( $signup_object = null ) {
    225                 ?>
    226                 <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php echo esc_html( sprintf( __( 'Select %s', 'buddypress' ), $signup_object->user_login ) ); ?></label>
     223        ?>
     224                <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( esc_html__( 'Select %s', 'buddypress' ), $signup_object->user_login ); ?></label>
    227225                <input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
    228226                <?php
     
    269267                );
    270268
    271                 echo $avatar . '<strong><a href="' . $activate_link .'" class="edit" title="' . esc_attr__( 'Activate', 'buddypress' ) . '">' . $signup_object->user_login .'</a></strong><br/>';
     269                echo $avatar . sprintf( '<strong><a href="%1$s" class="edit" title="%2$s">%3$s</a></strong><br/>', esc_url( $activate_link ), esc_attr__( 'Activate', 'buddypress' ), $signup_object->user_login );
    272270
    273271                $actions = array();
    274272
    275                 $actions['activate'] = '<a href="' . esc_url( $activate_link ) . '">' . __( 'Activate', 'buddypress' ) . '</a>';
    276 
    277                 $actions['resend'] = '<a href="' . esc_url( $email_link ) . '">' . __( 'Email', 'buddypress' ) . '</a>';
     273                $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) );
     274                $actions['resend']   = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) );
    278275
    279276                if ( current_user_can( 'delete_users' ) ) {
    280                         $actions['delete'] = '<a href="' . esc_url( $delete_link ) . '" class="delete">' . __( 'Delete', 'buddypress' ) . '</a>';
     277                        $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
    281278                }
    282279
    283280                $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
     281
    284282                echo $this->row_actions( $actions );
    285283        }
     
    304302         */
    305303        public function column_email( $signup_object = null ) {
    306                 echo '<a href="mailto:' . esc_attr( $signup_object->user_email ) . '">' . esc_html( $signup_object->user_email ) .'</a>';
     304                printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) );
    307305        }
    308306
     
    382380         */
    383381        public function prepare_items() {
    384                 global $usersearch, $wpdb, $mode;
    385 
    386                 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    387 
     382                global $usersearch, $mode;
     383
     384                $usersearch       = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    388385                $signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
    389 
    390                 $paged = $this->get_pagenum();
     386                $paged            = $this->get_pagenum();
    391387
    392388                $args = array(
     
    398394                );
    399395
    400                 if ( isset( $_REQUEST['orderby'] ) )
     396                if ( isset( $_REQUEST['orderby'] ) ) {
    401397                        $args['orderby'] = $_REQUEST['orderby'];
    402 
    403                 if ( isset( $_REQUEST['order'] ) )
     398                }
     399
     400                if ( isset( $_REQUEST['order'] ) ) {
    404401                        $args['order'] = $_REQUEST['order'];
    405 
    406                 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
    407 
     402                }
     403
     404                $mode    = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
    408405                $signups = BP_Signup::get( $args );
    409406
    410                 $this->items = $signups['signups'];
     407                $this->items         = $signups['signups'];
    411408                $this->signup_counts = $signups['total'];
    412409
     
    424421         * @uses WP_MS_Users_List_Table::get_views() to get the users views
    425422         */
    426         function get_views() {
     423        public function get_views() {
    427424                $views = parent::get_views();
    428425
    429                 $views['all'] = str_replace( 'class="current"', '', $views['all'] );
    430                         $class = ' class="current"';
    431 
    432                 $views['registered'] = '<a href="' . add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) . '"  class="current">' . sprintf( _x( 'Pending <span class="count">(%s)</span>', 'signup users', 'buddypress' ), number_format_i18n( $this->signup_counts ) ) . '</a>';
     426                // Remove the 'current' class from the 'All' link
     427                $views['all']        = str_replace( 'class="current"', '', $views['all'] );
     428                $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
    433429
    434430                return $views;
     
    443439                return apply_filters( 'bp_members_ms_signup_columns', array(
    444440                        'cb'         => '<input type="checkbox" />',
    445                         'username'   => __( 'Username', 'buddypress' ),
    446                         'name'       => __( 'Name', 'buddypress' ),
    447                         'email'      => __( 'Email', 'buddypress' ),
    448                         'registered' => __( 'Registered', 'buddypress' ),
    449                         'date_sent'  => __( 'Last Sent', 'buddypress' ),
    450                         'count_sent' => __( '# Times Emailed', 'buddypress' )
     441                        'username'   => __( 'Username',    'buddypress' ),
     442                        'name'       => __( 'Name',        'buddypress' ),
     443                        'email'      => __( 'Email',       'buddypress' ),
     444                        'registered' => __( 'Registered',  'buddypress' ),
     445                        'date_sent'  => __( 'Last Sent',   'buddypress' ),
     446                        'count_sent' => __( 'Emails Sent', 'buddypress' )
    451447                ) );
    452448        }
     
    460456                $actions = array(
    461457                        'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
    462                         'resend'   => _x( 'Email', 'Pending signup action', 'buddypress' ),
     458                        'resend'   => _x( 'Email',    'Pending signup action', 'buddypress' ),
    463459                );
    464460
     
    484480
    485481                        if ( current_user_can( 'manage_network_users' ) ) {
    486                                 $link = '<a href="' . esc_url( network_admin_url( 'settings.php' ) ) . '">' . esc_html__( 'Edit settings', 'buddypress' ) . '</a>';
     482                                $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) );
    487483                        }
    488484
     
    536532         */
    537533        public function column_cb( $signup_object = null ) {
    538                 ?>
    539                 <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php echo esc_html( sprintf( __( 'Select %s', 'buddypress' ), $signup_object->user_login ) ); ?></label>
     534        ?>
     535                <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( esc_html__( 'Select %s', 'buddypress' ), $signup_object->user_login ); ?></label>
    540536                <input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
    541537                <?php
     
    582578                );
    583579
    584                 echo $avatar . '<strong><a href="' . esc_url( $activate_link ) .'" class="edit" title="' . esc_attr__( 'Activate', 'buddypress' ) . '">' . $signup_object->user_login .'</a></strong><br/>';
    585 
    586                 $actions['activate'] = '<a href="' . esc_url( $activate_link ) . '">' . __( 'Activate', 'buddypress' ) . '</a>';
    587 
    588                 $actions['resend'] = '<a href="' . esc_url( $email_link ) . '">' . __( 'Email', 'buddypress' ) . '</a>';
     580                echo $avatar . sprintf( '<strong><a href="%1$s" class="edit" title="%2$s">%3$s</a></strong><br/>', esc_url( $activate_link ), esc_attr__( 'Activate', 'buddypress' ), $signup_object->user_login );
     581
     582                $actions = array();
     583
     584                $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) );
     585                $actions['resend']   = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link    ), __( 'Email',    'buddypress' ) );
    589586
    590587                if ( current_user_can( 'delete_users' ) ) {
    591                         $actions['delete'] = '<a href="' . esc_url( $delete_link ) . '" class="delete">' . __( 'Delete', 'buddypress' ) . '</a>';
     588                        $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
    592589                }
    593590
    594591                $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
     592
    595593                echo $this->row_actions( $actions );
    596594        }
     
    615613         */
    616614        public function column_email( $signup_object = null ) {
    617                 echo '<a href="mailto:' . esc_attr( $signup_object->user_email ) . '">' . esc_html( $signup_object->user_email ) .'</a>';
     615                printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) );
    618616        }
    619617
     
    628626                global $mode;
    629627
    630                 if ( 'list' == $mode ) {
     628                if ( 'list' === $mode ) {
    631629                        $date = 'Y/m/d';
    632630                } else {
     
    645643                global $mode;
    646644
    647                 if ( 'list' == $mode ) {
     645                if ( 'list' === $mode ) {
    648646                        $date = 'Y/m/d';
    649647                } else {
Note: See TracChangeset for help on using the changeset viewer.