@@ -302,33 +302,52 @@ function wp_dashboard_right_now() {
302302 <div class="main">
303303 <ul>
304304 <?php
305- // Posts and Pages.
306- foreach ( array ( 'post ' , 'page ' ) as $ post_type ) {
307- $ num_posts = wp_count_posts ( $ post_type );
308-
309- if ( $ num_posts && $ num_posts ->publish ) {
310- if ( 'post ' === $ post_type ) {
311- /* translators: %s: Number of posts. */
312- $ text = _n ( '%s Published post ' , '%s Published posts ' , $ num_posts ->publish );
305+ // At a Glance Post Types.
306+ foreach ( get_post_types ( array ( 'at_a_glance ' => true ), 'objects ' ) as $ post_type_object ) {
307+ $ post_type = $ post_type_object ->name ;
308+ $ num_posts = wp_count_posts ( $ post_type );
309+ $ num_post_published = intval ( $ num_posts ->publish );
310+
311+ if ( $ num_posts && $ num_post_published ) {
312+ if ( 1 === $ num_post_published ) {
313+ $ post_label = $ post_type_object ->labels ->singular_name ;
313314 } else {
314- /* translators: %s: Number of pages. */
315- $ text = _n ( '%s Published page ' , '%s Published pages ' , $ num_posts ->publish );
315+ $ post_label = $ post_type_object ->labels ->name ;
316316 }
317+ $ text = number_format_i18n ( $ num_post_published ) . ' ' . $ post_label ;
317318
318- $ text = sprintf ( $ text , number_format_i18n ( $ num_posts ->publish ) );
319- $ post_type_object = get_post_type_object ( $ post_type );
319+ $ icon_class = '' ;
320320
321- if ( $ post_type_object && current_user_can ( $ post_type_object ->cap ->edit_posts ) ) {
321+ if ( str_starts_with ( $ post_type_object ->menu_icon , 'dashicons- ' ) ) {
322+ $ icon_class = $ post_type_object ->menu_icon ;
323+ } elseif ( str_starts_with ( $ post_type_object ->menu_icon , 'data:image/svg+xml;base64, ' ) ) {
324+ printf (
325+ '<style>
326+ #dashboard_right_now li.%1$s-count a:before,
327+ #dashboard_right_now li.%1$s-count > span:before {
328+ content: url( \'%2$s \' );
329+ height: auto;
330+ width: 20px;
331+ }
332+ </style> ' ,
333+ $ post_type ,
334+ $ post_type_object ->menu_icon
335+ );
336+ }
337+
338+ $ class_attr = $ icon_class ? sprintf ( ' class="%s" ' , $ icon_class ) : '' ;
339+
340+ if ( current_user_can ( $ post_type_object ->cap ->edit_posts ) ) {
322341 $ url = add_query_arg (
323342 array (
324343 'post_status ' => 'publish ' ,
325344 'post_type ' => $ post_type ,
326345 ),
327346 admin_url ( 'edit.php ' )
328347 );
329- printf ( '<li class="%1$s-count"><a href="%2$s">%3 $s</a></li> ' , $ post_type , esc_url ( $ url ), esc_html ( $ text ) );
348+ printf ( '<li class="%1$s-count"><a%3$s href="%2$s">%4 $s</a></li> ' , $ post_type , esc_url ( $ url ), $ class_attr , esc_html ( $ text ) );
330349 } else {
331- printf ( '<li class="%1$s-count"><span>%2$s</span></li> ' , $ post_type , $ text );
350+ printf ( '<li class="%1$s-count"><span%3$s >%2$s</span></li> ' , $ post_type , esc_html ( $ text ), $ class_attr );
332351 }
333352 }
334353 }
0 commit comments