Ticket #28673: 28673-featured-grouping-2.diff
| File 28673-featured-grouping-2.diff, 3.1 KB (added by , 12 years ago) |
|---|
-
wp-admin/css/list-tables.css
1336 1336 clear: right; 1337 1337 } 1338 1338 1339 .plugin-group { 1340 padding-top: 2em; 1341 } 1342 1339 1343 /* ms */ 1340 1344 /* Background Color for Site Status */ 1341 1345 .wp-list-table .site-deleted { -
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; 14 var $groups = array(); 11 15 12 16 public function ajax_user_can() { 13 17 return current_user_can('install_plugins'); … … 85 89 break; 86 90 87 91 case 'featured': 92 $args['fields']['group'] = true; 93 $this->orderby = 'group'; 94 // No break! 88 95 case 'popular': 89 96 case 'new': 90 97 case 'beta': … … 129 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>' ); 130 137 131 138 $this->items = $api->plugins; 139 140 if ( $this->orderby ) { 141 uasort( $this->items, array( $this, '_order_callback' ) ); 142 } 132 143 133 144 $this->set_pagination_args( array( 134 145 'total_items' => $api->info['results'], 135 146 'per_page' => $args['per_page'], 136 147 ) ); 148 149 if ( isset( $api->info['groups'] ) ) 150 $this->groups = $api->info['groups']; 137 151 } 138 152 139 153 public function no_items() { … … 242 256 'description' => __( 'Description' ), 243 257 ); 244 258 } 259 260 public function _order_callback( $plugin_a, $plugin_b ) { 245 261 262 $orderby = $this->orderby; 263 if ( !isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) 264 return 0; 265 266 $a = $plugin_a->$orderby; 267 $b = $plugin_b->$orderby; 268 269 if ( $a == $b ) 270 return 0; 271 272 if ( 'DESC' == $this->order ) 273 return ( $a < $b ) ? 1 : -1; 274 else 275 return ( $a < $b ) ? -1 : 1; 276 } 277 278 246 279 public function display_rows() { 247 280 $plugins_allowedtags = array( 248 281 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), … … 258 291 $style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : ''; 259 292 } 260 293 294 $group = null; 295 261 296 foreach ( (array) $this->items as $plugin ) { 262 297 if ( is_object( $plugin ) ) 263 298 $plugin = (array) $plugin; 264 299 300 // Display the group heading if there is one 301 if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { 302 if ( isset( $this->groups[ $plugin['group'] ] ) ) 303 $group_name = translate( $this->groups[ $plugin['group'] ] ); // Does this need context? 304 else 305 $group_name = $plugin['group']; 306 echo '<h3 class="plugin-group clear">' . esc_html( $group_name ) . '</h3>'; 307 echo '<div class="clear"></div>'; 308 $group = $plugin['group']; 309 } 310 265 311 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 266 312 267 313 //Remove any HTML from the description.