Ticket #27316: class-wp-plugin-install-list-table.php.patch
File class-wp-plugin-install-list-table.php.patch, 1.9 KB (added by , 10 years ago) |
---|
-
class-wp-plugin-install-list-table.php
163 163 case 'favorites': 164 164 $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); 165 165 update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); 166 if ( $user ) 166 if ( $user ) { 167 167 $args['user'] = $user; 168 else 168 $search = isset( $_GET['search'] ) ? wp_unslash( $_GET['search'] ) : false; 169 if ($search) 170 $args['s'] = $search; 171 } else { 169 172 $args = false; 170 173 } 171 174 add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); 172 175 break; 173 176 … … 190 193 191 194 if ( !$args ) 192 195 return; 196 197 if ( isset( $args['s'] ) ){ 198 $per_page_limit = $args['per_page']; 199 $args['per_page'] = -1; 200 } 193 201 194 202 $api = plugins_api( 'query_plugins', $args ); 195 203 … … 199 207 } 200 208 201 209 $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 } 202 220 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 203 226 if ( $this->orderby ) { 204 227 uasort( $this->items, array( $this, 'order_callback' ) ); 205 228 }