Making WordPress.org

Changeset 13200


Ignore:
Timestamp:
02/12/2024 06:40:39 AM (17 months ago)
Author:
dd32
Message:

Registration: Admin tools: Sort the recently banned list by the banned date.

This also includes a PHP Warning fix and whitespace changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/class-user-registrations-list-table.php

    r12207 r13200  
    7070                }
    7171
    72                 $url = add_query_arg( 'view', $item[0], $url );
     72                if ( 'all' !== $item[0] ) {
     73                    $url = add_query_arg( 'view', $item[0], $url );
     74                }
    7375
    7476                return sprintf(
     
    128130
    129131        // Join if the view needs the users or description table.
    130         if ( strpos( $where . $join, 'users.' ) || strpos( $where, 'description.' ) ) {
     132        if ( strpos( $where . $join, 'users.' ) || strpos( $where, 'description.' ) || (  'banned-users' === $view ?: ( $_REQUEST['view'] ?? 'all' )  ) ) {
    131133            $join .= " LEFT JOIN {$wpdb->users} users ON registrations.created = 1 AND registrations.user_login = users.user_login";
    132134        }
    133135        if ( strpos( $where, 'description.' ) ) {
    134136            $join .= " LEFT JOIN {$wpdb->usermeta} description ON users.ID = description.user_id AND description.meta_key = 'description'";
     137        }
     138
     139        if ( 'banned-users' === $view ?: ( $_REQUEST['view'] ?? 'all' ) ) {
     140            $join .= " LEFT JOIN {$wpdb->usermeta} notes ON users.ID = notes.user_id AND notes.meta_key = '_wporg_bbp_user_notes'";
    135141        }
    136142
     
    162168            array(),
    163169            $this->get_sortable_columns(),
    164        );
    165 
    166        $sort_column = $_GET['orderby'] ?? 'pending_id';
    167        $sort_order = strtoupper( $_GET['order'] ?? 'DESC' );
    168 
    169        if ( ! in_array( $sort_order, [ 'DESC', 'ASC' ] ) ) {
    170            $sort_order = 'DESC';
    171        }
    172        if ( ! isset( $this->get_sortable_columns()[ $sort_column ] ) ) {
    173            $sort_column = 'pending_id';
    174        }
    175 
    176        $per_page     = $this->get_items_per_page( 'users_per_page', 100 );
    177        $current_page = $this->get_pagenum();
    178 
    179        $join_where = $this->get_join_where_sql();
    180 
    181        $per_page_offset = ($current_page-1) * $per_page;
     170        );
     171
     172        $sort_column = $_GET['orderby'] ?? 'pending_id';
     173        $sort_order = strtoupper( $_GET['order'] ?? 'DESC' );
     174
     175        if ( ! in_array( $sort_order, [ 'DESC', 'ASC' ] ) ) {
     176            $sort_order = 'DESC';
     177        }
     178        if ( ! isset( $this->get_sortable_columns()[ $sort_column ] ) ) {
     179            $sort_column = 'pending_id';
     180        }
     181        if ( 'banned-users' === ( $_GET['view'] ?? '' ) ) {
     182            $sort_column = 'notes.umeta_id';
     183            $sort_order = 'DESC';
     184        }
     185
     186        $per_page     = $this->get_items_per_page( 'users_per_page', 100 );
     187        $current_page = $this->get_pagenum();
     188
     189        $join_where = $this->get_join_where_sql();
     190
     191        $per_page_offset = ($current_page-1) * $per_page;
    182192
    183193        $this->items = $wpdb->get_results(
     
    431441    function link_to_search( $s ) {
    432442        $parts = preg_split( '/([^\w\.-])/ui', $s, -1, PREG_SPLIT_DELIM_CAPTURE );
     443        if ( ! $parts ) {
     444            $parts = array( $s );
     445        }
    433446
    434447        return implode( '', array_map( function( $s ) {
Note: See TracChangeset for help on using the changeset viewer.