Make WordPress Core

Ticket #27316: class-wp-plugin-install-list-table.php.patch

File class-wp-plugin-install-list-table.php.patch, 1.9 KB (added by kidsguide, 10 years ago)
  • class-wp-plugin-install-list-table.php

     
    163163                        case 'favorites':
    164164                                $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
    165165                                update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
    166                                 if ( $user )
     166                                if ( $user ) {
    167167                                        $args['user'] = $user;
    168                                 else
     168                                        $search = isset( $_GET['search'] ) ? wp_unslash( $_GET['search'] ) : false;
     169                                        if ($search)
     170                                        $args['s'] = $search;
     171                                } else {
    169172                                        $args = false;
    170 
     173                                }
    171174                                add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
    172175                                break;
    173176
     
    190193
    191194                if ( !$args )
    192195                        return;
     196                       
     197                if ( isset( $args['s'] ) ){
     198                        $per_page_limit = $args['per_page'];
     199                        $args['per_page'] = -1;
     200                }
    193201
    194202                $api = plugins_api( 'query_plugins', $args );
    195203
     
    199207                }
    200208
    201209                $this->items = $api->plugins;
     210               
     211                if( isset( $args['s'] )){
     212                        $args['per_page'] = $per_page_limit;
     213                       
     214                        foreach ($this->items as $key => $item){ 
     215                                if (stripos($item->name, $args['s']) === false){ 
     216                                        unset ($this->items[ $key ]); 
     217                                        $api->info['results']--; 
     218                                } 
     219                        } 
    202220
     221                        if ( isset( $args['page']) ){ 
     222                                $this->items = array_slice( $this->items, min( ( $args['page'] * $args['per_page'] ) - $args['per_page'], sizeof ($this->items) ) ); 
     223                        } 
     224                } 
     225
    203226                if ( $this->orderby ) {
    204227                        uasort( $this->items, array( $this, 'order_callback' ) );
    205228                }