Ticket #28673: 28673-featured-grouping.diff
| File 28673-featured-grouping.diff, 2.4 KB (added by , 12 years ago) |
|---|
-
wp-admin/includes/class-wp-plugin-install-list-table.php
8 8 * @access private 9 9 */ 10 10 class WP_Plugin_Install_List_Table extends WP_List_Table { 11 12 var $order = 'ASC'; 13 var $orderby = null; 11 14 12 15 public function ajax_user_can() { 13 16 return current_user_can('install_plugins'); … … 85 88 break; 86 89 87 90 case 'featured': 91 $args['fields']['group'] = true; 92 $this->orderby = 'group'; 93 // No break! 88 94 case 'popular': 89 95 case 'new': 90 96 case 'beta': … … 129 135 wp_die( $api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); 130 136 131 137 $this->items = $api->plugins; 138 139 if ( $this->orderby ) { 140 uasort( $this->items, array( $this, '_order_callback' ) ); 141 } 132 142 133 143 $this->set_pagination_args( array( 134 144 'total_items' => $api->info['results'], … … 242 252 'description' => __( 'Description' ), 243 253 ); 244 254 } 255 256 public function _order_callback( $plugin_a, $plugin_b ) { 245 257 258 $orderby = $this->orderby; 259 if ( !isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) 260 return 0; 261 262 $a = $plugin_a->$orderby; 263 $b = $plugin_b->$orderby; 264 265 if ( $a == $b ) 266 return 0; 267 268 if ( 'DESC' == $this->order ) 269 return ( $a < $b ) ? 1 : -1; 270 else 271 return ( $a < $b ) ? -1 : 1; 272 } 273 274 246 275 public function display_rows() { 247 276 $plugins_allowedtags = array( 248 277 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), … … 258 287 $style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : ''; 259 288 } 260 289 290 $group = null; 291 261 292 foreach ( (array) $this->items as $plugin ) { 262 293 if ( is_object( $plugin ) ) 263 294 $plugin = (array) $plugin; 264 295 296 // Display the group heading if there is one 297 if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { 298 // FIXME: replace ucwords with some i18n magic 299 echo '<h3 class="plugin-group clear">' . esc_html( ucwords( $plugin['group'] ) ) . '</h3>'; 300 echo '<div class="clear"></div>'; 301 $group = $plugin['group']; 302 } 303 265 304 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 266 305 267 306 //Remove any HTML from the description.