Changeset 29225
- Timestamp:
- 07/18/2014 07:34:47 PM (9 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/list-tables.css
r29219 r29225 1217 1217 1218 1218 /* Plugin card table view */ 1219 .plugin-group { 1220 overflow: hidden; /* clearfix */ 1221 margin-top: 1.5em; 1222 } 1223 1224 .plugin-group:first-of-type, 1225 .plugin-group h3 { 1226 margin-top: 0; 1227 } 1228 1219 1229 .plugin-card { 1220 1230 float: left; -
trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php
r29219 r29225 10 10 class WP_Plugin_Install_List_Table extends WP_List_Table { 11 11 12 var $order = 'ASC'; 13 var $orderby = null; 14 var $groups = array(); 15 12 16 public function ajax_user_can() { 13 17 return current_user_can('install_plugins'); … … 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': … … 131 138 $this->items = $api->plugins; 132 139 140 if ( $this->orderby ) { 141 uasort( $this->items, array( $this, '_order_callback' ) ); 142 } 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 … … 244 258 } 245 259 260 public function _order_callback( $plugin_a, $plugin_b ) { 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( … … 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 307 // Starting a new group, close off the divs of the last one 308 if ( ! empty( $group ) ) { 309 echo '</div></div>'; 310 } 311 312 echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; 313 // needs an extra wrapping div for nth-child selectors to work 314 echo '<div class="plugin-items">'; 315 316 $group = $plugin['group']; 317 } 265 318 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 266 319
Note: See TracChangeset
for help on using the changeset viewer.