Ticket #27316: 27316.diff
File 27316.diff, 3.0 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/plugin-install.php
206 206 */ 207 207 function install_plugins_favorites_form() { 208 208 $user = ! empty( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); 209 $search = ! empty( $_GET['search'] ) ? wp_unslash( $_GET['search'] ) : ''; 209 210 ?> 210 211 <p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> 211 212 <form method="get" action=""> … … 213 214 <p> 214 215 <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> 215 216 <input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" /> 217 (<input type="search" id="search" name="search" value="<?php echo esc_attr( $search ); ?>" placeholder="<?php _e( 'Search' ); ?>" />) 216 218 <input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> 217 219 </p> 218 220 </form> … … 450 452 exit; 451 453 } 452 454 add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); 455 -
wp-admin/includes/class-wp-plugin-install-list-table.php
91 91 case 'favorites': 92 92 $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); 93 93 update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); 94 if ( $user ) 94 if ( $user ){ 95 95 $args['user'] = $user; 96 else 96 97 $search = isset( $_GET['search'] ) ? wp_unslash( $_GET['search'] ) : false; 98 if ($search) 99 $args['s'] = $search; 100 } else { 97 101 $args = false; 102 } 98 103 99 104 add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); 100 105 break; … … 120 125 if ( !$args ) 121 126 return; 122 127 128 if ( isset( $args['s'] ) ){ 129 $per_page_limit = $args['per_page']; 130 $args['per_page'] = -1; 131 } 132 123 133 $api = plugins_api( 'query_plugins', $args ); 124 134 125 135 if ( is_wp_error( $api ) ) 126 136 wp_die( $api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); 127 137 128 138 $this->items = $api->plugins; 139 if( isset( $args['s'] )){ 140 $args['per_page'] = $per_page_limit; 129 141 142 foreach ($this->items as $key => $item){ 143 if (stripos($item->name, $args['s']) === false){ 144 unset ($this->items[ $key ]); 145 $api->info['results']--; 146 } 147 } 148 149 if ( isset( $args['page']) ){ 150 $this->items = array_slice( $this->items, min( ( $args['page'] * $args['per_page'] ) - $args['per_page'], sizeof ($this->items) ) ); 151 } 152 } 153 130 154 $this->set_pagination_args( array( 131 155 'total_items' => $api->info['results'], 132 156 'per_page' => $args['per_page'], … … 278 302 } 279 303 } 280 304 } 305