Ticket #28785: 28785-plugin-card-table-draft.6.diff
File 28785-plugin-card-table-draft.6.diff, 9.6 KB (added by , 11 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': … … 154 154 return $display_tabs; 155 155 } 156 156 157 /** 158 * Override the parent display() so we can provide a different container. 159 */ 160 public function display() { 161 $singular = $this->_args['singular']; 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 157 179 protected function display_tablenav( $which ) { 158 180 if ( 'top' == $which ) { ?> 159 181 <div class="tablenav top"> … … 211 233 $plugin = (array) $plugin; 212 234 213 235 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 214 //Limit description to 400char, and remove any HTML. 215 $description = strip_tags( $plugin['description'] ); 216 if ( strlen( $description ) > 400 ) 217 $description = mb_substr( $description, 0, 400 ) . '…'; 218 //remove any trailing entities 219 $description = preg_replace( '/&[^;\s]{0,6}$/', '', $description ); 220 //strip leading/trailing & multiple consecutive lines 221 $description = trim( $description ); 222 $description = preg_replace( "|(\r?\n)+|", "\n", $description ); 223 //\n => <br> 224 $description = nl2br( $description ); 236 //Remove any HTML from the description. 237 $description = strip_tags( $plugin['short_description'] ); 225 238 $version = wp_kses( $plugin['version'], $plugins_allowedtags ); 226 239 227 240 $name = strip_tags( $title . ' ' . $version ); 228 241 229 242 $author = $plugin['author']; 230 243 if ( ! empty( $plugin['author'] ) ) 231 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . ' .</cite>';244 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; 232 245 233 246 $author = wp_kses( $author, $plugins_allowedtags ); 234 247 235 248 $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 249 240 250 if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { 241 251 $status = install_plugin_install_status( $plugin ); … … 243 253 switch ( $status['status'] ) { 244 254 case 'install': 245 255 if ( $status['url'] ) 246 $action_links[] = '<a class="install-now " href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';256 $action_links[] = '<a class="install-now button" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>'; 247 257 break; 248 258 case 'update_available': 249 259 if ( $status['url'] ) 250 $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . __( 'Update Now' ) . '</a>';260 $action_links[] = '<a class="button" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . __( 'Update Now' ) . '</a>'; 251 261 break; 252 262 case 'latest_installed': 253 263 case 'newer_installed': 254 $action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>';264 $action_links[] = '<span class="button button-disabled" title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>'; 255 265 break; 256 266 } 257 267 } 258 268 269 $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . 270 '&TB_iframe=true&width=600&height=550' ); 271 259 272 /** 273 * Filter the details link for a plugin. 274 * 275 * @since 4.0 276 * 277 * @param array $details_link Link to view the current plugin's details. 278 * @param array $plugin The plugin currently being listed. 279 */ 280 $details_link = apply_filters( 'plugin_install_details_link', $details_link, $plugin ); 281 282 $action_links[] = '<a href="' . esc_attr( $details_link ) . '" class="thickbox" title="' . 283 esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __( 'More Details' ) . '</a>'; 284 285 /** 260 286 * Filter the install action links for a plugin. 261 287 * 262 288 * @since 2.7.0 … … 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><a href="<?php echo esc_attr( $details_link ) ?>" class="thickbox"><?php echo $title; ?></a></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 float: left; 1221 margin: 0 8px 16px; 1222 width: 48.5%; 1223 width: -webkit-calc( 50% - 8px ); 1224 width: calc( 50% - 8px ); 1225 background-color: #fff; 1226 border: 1px solid #dedede; 1227 box-sizing: border-box; 1228 } 1229 @media screen and ( max-width: 782px ) { 1230 .plugin-card { 1231 margin-left: 0; 1232 margin-right: 0; 1233 width: 100%; 1234 } 1235 } 1236 .plugin-card:nth-child(odd) { 1237 clear: both; 1238 margin-left: 0; 1239 } 1240 .plugin-card:nth-child(even) { 1241 margin-right: 0 1242 } 1243 .plugin-card-top { 1244 padding: 20px 20px 10px; 1245 } 1246 div.action-links, 1247 .plugin-action-buttons { 1248 margin: 0; /* Override existing margins */ 1249 } 1250 .plugin-card h4 { 1251 float: left; 1252 margin: 0 0 12px; 1253 font-size: 18px; 1254 } 1255 .plugin-card .desc { 1256 clear: left; 1257 } 1258 .plugin-action-buttons { 1259 float: right; 1260 margin-left: 2em; 1261 margin-bottom: 1em; 1262 text-align: right; 1263 } 1264 .plugin-action-buttons li { 1265 margin-bottom: 10px; 1266 } 1267 .plugin-card-bottom { 1268 clear: both; 1269 padding: 12px 20px; 1270 background-color: #fafafa; 1271 border-top: 1px solid #dedede; 1272 overflow: hidden; 1273 } 1274 .plugin-card-bottom .star-rating { 1275 display: inline; 1276 } 1277 .plugin-card .column-rating { 1278 line-height: 23px; 1279 } 1280 .plugin-card .column-rating, 1281 .plugin-card .column-updated { 1282 margin-bottom: 4px; 1283 } 1284 .plugin-card .column-rating, 1285 .plugin-card .column-downloaded { 1286 float: left; 1287 clear: left; 1288 } 1289 .plugin-card .column-updated, 1290 .plugin-card .column-compatibility { 1291 float: right; 1292 clear: right; 1293 } 1294 1218 1295 /* ms */ 1219 1296 /* Background Color for Site Status */ 1220 1297 .wp-list-table .site-deleted {