Ticket #28785: 28785-plugin-card-table-draft.4.diff
File 28785-plugin-card-table-draft.4.diff, 8.8 KB (added by , 10 years ago) |
---|
-
wp-admin/includes/class-wp-plugin-install-list-table.php
63 63 if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) 64 64 $tab = key( $tabs ); 65 65 66 $args = array( 'page' => $paged, 'per_page' => $per_page );66 $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => array( 'last_updated' => true, 'downloaded' => true ) ); 67 67 68 68 switch ( $tab ) { 69 69 case 'search': … … 153 153 154 154 return $display_tabs; 155 155 } 156 157 /** 158 * Override the parent display() so we can provide a different container. 159 */ 160 public function display() { 161 $singular = $this->_args['singular']; 156 162 163 $this->display_tablenav( 'top' ); 164 165 ?> 166 <div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> 167 168 <div id="the-list"<?php 169 if ( $singular ) { 170 echo " data-wp-lists='list:$singular'"; 171 } ?>> 172 <?php $this->display_rows_or_placeholder(); ?> 173 </div> 174 </div> 175 <?php 176 $this->display_tablenav( 'bottom' ); 177 } 178 179 157 180 protected function display_tablenav( $which ) { 158 181 if ( 'top' == $which ) { ?> 159 182 <div class="tablenav top"> … … 211 234 $plugin = (array) $plugin; 212 235 213 236 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 214 //Limit description to 40 0char, and remove any HTML.237 //Limit description to 40 words, and remove any HTML. 215 238 $description = strip_tags( $plugin['description'] ); 239 $description = wp_trim_words( $description, 40 ); 240 // Just in case it's still too long, trim it to 400 characters. 216 241 if ( strlen( $description ) > 400 ) 217 242 $description = mb_substr( $description, 0, 400 ) . '…'; 218 243 //remove any trailing entities … … 221 246 $description = trim( $description ); 222 247 $description = preg_replace( "|(\r?\n)+|", "\n", $description ); 223 248 //\n => <br> 224 $description = nl2br( $description );249 #$description = nl2br( $description ); 225 250 $version = wp_kses( $plugin['version'], $plugins_allowedtags ); 226 251 227 252 $name = strip_tags( $title . ' ' . $version ); 228 253 229 254 $author = $plugin['author']; 230 255 if ( ! empty( $plugin['author'] ) ) 231 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . ' .</cite>';256 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; 232 257 233 258 $author = wp_kses( $author, $plugins_allowedtags ); 234 259 235 260 $action_links = array(); 236 $action_links[] = '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .237 '&TB_iframe=true&width=600&height=550' ) . '" class="thickbox" title="' .238 esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __( 'Details' ) . '</a>';239 261 240 262 if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { 241 263 $status = install_plugin_install_status( $plugin ); … … 243 265 switch ( $status['status'] ) { 244 266 case 'install': 245 267 if ( $status['url'] ) 246 $action_links[] = '<a class="install-now " href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';268 $action_links[] = '<a class="install-now button button-primary" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>'; 247 269 break; 248 270 case 'update_available': 249 271 if ( $status['url'] ) 250 $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . __( 'Update Now' ) . '</a>';272 $action_links[] = '<a class="button button-primary" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . __( 'Update Now' ) . '</a>'; 251 273 break; 252 274 case 'latest_installed': 253 275 case 'newer_installed': 254 $action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>';276 $action_links[] = '<span class="button button-primary button-disabled" title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>'; 255 277 break; 256 278 } 257 279 } 258 280 281 $action_links[] = '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . 282 '&TB_iframe=true&width=600&height=550' ) . '" class="thickbox button" title="' . 283 esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __( 'More Details' ) . '</a>'; 284 259 285 /** 260 286 * Filter the install action links for a plugin. 261 287 * … … 266 292 */ 267 293 $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); 268 294 ?> 269 <tr> 270 <td class="name column-name"<?php echo $style['name']; ?>><strong><?php echo $title; ?></strong> 271 <div class="action-links"><?php if ( !empty( $action_links ) ) echo implode( ' | ', $action_links ); ?></div> 272 </td> 273 <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td> 274 <td class="vers column-rating"<?php echo $style['rating']; ?>> 275 <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?> 276 </td> 277 <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td> 278 </tr> 295 <div class="plugin-card"> 296 <div class="plugin-card-top"> 297 <div class="name column-name"<?php echo $style['name']; ?>><h4><?php echo $title; ?></h4> 298 <div class="action-links"><?php if ( !empty( $action_links ) ) echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li>'; ?></div> 299 </div> 300 <div class="desc column-description"<?php echo $style['description']; ?>> 301 <p><?php echo $description ?> 302 <span class="authors"> 303 <?php echo $author; ?> 304 <?php if ( count( $plugin['contributors'] ) > 1 ) echo sprintf( __( '+ %d more' ), count( $plugin['contributors'] ) -1 ); ?>. 305 </span> 306 </p> 307 </div> 308 </div> 309 <div class="plugin-card-bottom"> 310 <div class="vers column-rating"<?php echo $style['rating']; ?>> 311 <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?> 312 <span class="num-ratings">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> 313 </div> 314 <div class="column-updated"><?php echo __('<strong>Last updated:</strong>') . ' '. sprintf( '%s ago', human_time_diff( strtotime($plugin['last_updated']) ) ); ?></div> 315 <div class="column-downloaded"><?php echo sprintf( __('%s downloads'), number_format_i18n( $plugin['downloaded'] ) ); ?></div> 316 <div class="column-compatibility"> 317 <?php 318 if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) 319 echo __('<strong>Untested</strong> with your install'); 320 321 else if ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) 322 echo __('<strong>Incompatible</strong> with your install'); 323 else 324 echo __('<strong>Compatible</strong> with your install'); 325 ?> 326 </div> 327 </div> 328 </div> 279 329 <?php 280 330 } 281 331 } -
wp-admin/css/list-tables.css
1215 1215 margin: 2.5em 0 8px; 1216 1216 } 1217 1217 1218 /* Plugin card table view */ 1219 .plugin-card { 1220 width: 45%; 1221 float: left; 1222 margin: 0 2em 2em 0; 1223 background-color: #fff; 1224 border: 1px solid #dedede; 1225 } 1226 @media screen and ( max-width: 782px ) { 1227 .plugin-card { 1228 width: 100%; 1229 } 1230 } 1231 .plugin-card:nth-child(odd) { 1232 clear: both; 1233 } 1234 .plugin-card-top { 1235 padding: 0 1em; 1236 } 1237 .plugin-card-bottom { 1238 background-color: #fafafa; 1239 border-top: 1px solid #dedede; 1240 padding: 1em; 1241 overflow: hidden; /* Makes the container full height. I have no idea why this works. */ 1242 } 1243 .plugin-card-bottom .star-rating { 1244 display: inline; 1245 } 1246 .plugin-card h4 { 1247 float: left; 1248 font-size: 16px; 1249 margin-top: 1em; 1250 } 1251 .plugin-card .desc { 1252 clear: left; 1253 } 1254 .plugin-card .column-rating, .plugin-card .column-downloaded { 1255 float: left; 1256 clear: left; 1257 } 1258 .plugin-card .column-updated, .plugin-card .column-compatibility { 1259 float: right; 1260 clear: right; 1261 } 1262 .plugin-action-buttons { 1263 float: right; 1264 text-align: right; 1265 margin-left: 2em; 1266 } 1267 1268 1218 1269 /* ms */ 1219 1270 /* Background Color for Site Status */ 1220 1271 .wp-list-table .site-deleted {