Make WordPress Core

Changeset 64799


Ignore:
Timestamp:
10/27/2026 10:41:08 AM (13 days ago)
Author:
wildworks
Message:

Administration: Use SVG icons in the At a Glance widget

Replace the Dashicons in the At a Glance dashboard widget with icons from the icon library, so the widget matches the SVG icons now used in the admin menu and admin bar. Items added by plugins fall back to a default SVG icon, while items that provide their own Dashicon via CSS or their own inline SVG icon keep it.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/14548

Follow-up to [64583].

Props fushar, joen, ocean90, peterwilsoncc, suryakantupadhyay, wildworks.
Fixes #66347.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/edit-comments.js

    r63600 r64799  
    153153                }
    154154
    155                 $( '.comment-count a', '#dashboard_right_now' ).text( response.i18n_comments_text );
     155                $( '.comment-count .comments-count-text', '#dashboard_right_now' ).text( response.i18n_comments_text );
    156156        };
    157157
  • trunk/src/wp-admin/css/dashboard.css

    r64593 r64799  
    353353.welcome-panel .welcome-icon::before,
    354354#dashboard_right_now li a::before,
    355 #dashboard_right_now li span::before,
    356 #dashboard_right_now .search-engines-info::before {
     355#dashboard_right_now li span::before {
    357356        color: #646970;
    358357        font: 400 20px/1 dashicons;
    … …  
    434433/* Right Now specific Icons styles */
    435434
    436 #dashboard_right_now .search-engines-info::before,
    437435#dashboard_right_now li a::before,
    438 #dashboard_right_now li > span::before { /* get only the first level span to exclude screen-reader-text in mu-storage */
     436#dashboard_right_now li > span::before {
    439437        padding: 0 5px 0 0;
    440         /* generic icon for items added by CPTs ? */
    441         content: "\f159";
    442         content: "\f159" / "";
    443 }
    444 
    445 #dashboard_right_now .page-count a::before,
    446 #dashboard_right_now .page-count span::before {
    447         content: "\f105";
    448         content: "\f105" / "";
    449 }
    450 
    451 #dashboard_right_now .post-count a::before,
    452 #dashboard_right_now .post-count span::before {
    453         content: "\f109";
    454         content: "\f109" / "";
    455 }
    456 
    457 #dashboard_right_now .comment-count a::before {
    458         content: "\f101";
    459         content: "\f101" / "";
    460 }
    461 
    462 #dashboard_right_now .comment-mod-count a::before {
    463         content: "\f125";
    464         content: "\f125" / "";
    465 }
    466 
    467 #dashboard_right_now .storage-count a::before {
    468         content: "\f104";
    469         content: "\f104" / "";
    470 }
    471 
    472 #dashboard_right_now .storage-count.warning a::before {
    473         content: "\f153";
    474         content: "\f153" / "";
    475 }
    476 
    477 #dashboard_right_now .search-engines-info::before {
    478         content: "\f348";
    479         content: "\f348" / "";
     438        /*
     439         * Default icon for plugin-added items: a copy of the core `asterisk` icon.
     440         * Plugins can still override `content` with a Dashicon.
     441         */
     442        content: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2024%2024%22%20style%3D%22fill%3A%20none%22%20stroke%3D%22%23646970%22%20stroke-width%3D%221.5%22%3E%3Cpath%20d%3D%22M5.72131%2015.625L12%2012M12%2012L18.2787%208.375M12%2012V4.75M12%2012L12%2019.25M12%2012L5.72131%208.375M12%2012L18.2787%2015.625%22%20stroke-linecap%3D%22square%22%20%2F%3E%3C%2Fsvg%3E");
     443        content: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2024%2024%22%20style%3D%22fill%3A%20none%22%20stroke%3D%22%23646970%22%20stroke-width%3D%221.5%22%3E%3Cpath%20d%3D%22M5.72131%2015.625L12%2012M12%2012L18.2787%208.375M12%2012V4.75M12%2012L12%2019.25M12%2012L5.72131%208.375M12%2012L18.2787%2015.625%22%20stroke-linecap%3D%22square%22%20%2F%3E%3C%2Fsvg%3E") / "";
     444}
     445
     446#dashboard_right_now li a:has(> svg)::before,
     447#dashboard_right_now li > span:has(> svg)::before {
     448        display: none;
     449}
     450
     451#dashboard_right_now li a:has(> svg),
     452#dashboard_right_now li > span:has(> svg),
     453#dashboard_right_now .search-engines-info a {
     454        display: inline-flex;
     455        align-items: flex-start;
     456        gap: 5px;
     457        /* Match the height of ::before icon rows so the floated list items don't snag. */
     458        vertical-align: top;
     459}
     460
     461#dashboard_right_now li a > svg,
     462#dashboard_right_now li > span > svg,
     463#dashboard_right_now .search-engines-info svg {
     464        flex: none;
     465        color: #646970;
     466}
     467
     468#dashboard_right_now .warning a > svg,
     469#dashboard_right_now .search-engines-info svg {
    480470        color: #d63638;
    481471}
  • trunk/src/wp-admin/includes/dashboard.php

    r64593 r64799  
    350350                        $text             = sprintf( $text, number_format_i18n( $num_posts->publish ) );
    351351                        $post_type_object = get_post_type_object( $post_type );
     352                        $icon             = wp_get_icon( 'post' === $post_type ? 'core-admin/pin' : 'core-admin/page', array( 'size' => 20 ) );
    352353
    353354                        if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
    … …  
    359360                                        admin_url( 'edit.php' )
    360361                                );
    361                                 printf( '<li class="%1$s-count"><a href="%2$s">%3$s</a></li>', $post_type, esc_url( $url ), esc_html( $text ) );
     362                                printf( '<li class="%1$s-count"><a href="%2$s">%3$s%4$s</a></li>', $post_type, esc_url( $url ), $icon, esc_html( $text ) );
    362363                        } else {
    363                                 printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
     364                                printf( '<li class="%1$s-count"><span>%2$s%3$s</span></li>', $post_type, $icon, esc_html( $text ) );
    364365                        }
    365366                }
    … …  
    374375                ?>
    375376                <li class="comment-count">
    376                         <a href="edit-comments.php"><?php echo $text; ?></a>
     377                        <a href="edit-comments.php"><?php echo wp_get_icon( 'core-admin/comment', array( 'size' => 20 ) ); ?><span class="comments-count-text"><?php echo $text; ?></span></a>
    377378                </li>
    378379                <?php
    … …  
    382383                ?>
    383384                <li class="comment-mod-count<?php echo ! $num_comm->moderated ? ' hidden' : ''; ?>">
    384                         <a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a>
     385                        <a href="edit-comments.php?comment_status=moderated"><?php echo wp_get_icon( 'core-admin/post-comments', array( 'size' => 20 ) ); ?><span class="comments-in-moderation-text"><?php echo $text; ?></span></a>
    385386                </li>
    386387                <?php
    … …  
    441442                $title_attr = '' === $title ? '' : " title='$title'";
    442443
    443                 echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$content</a></p>";
     444                $icon = wp_get_icon( 'core-admin/info', array( 'size' => 20 ) );
     445                echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$icon$content</a></p>";
    444446        }
    445447        ?>
    … …  
    19221924                        );
    19231925                        printf(
    1924                                 '<a href="%1$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
     1926                                '<a href="%1$s">%2$s%3$s<span class="screen-reader-text"> (%4$s)</span></a>',
    19251927                                esc_url( admin_url( 'upload.php' ) ),
     1928                                wp_get_icon( 'core-admin/media', array( 'size' => 20 ) ),
    19261929                                $text,
    19271930                                /* translators: Hidden accessibility text. */
    … …  
    19381941                        );
    19391942                        printf(
    1940                                 '<a href="%1$s" class="musublink">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
     1943                                '<a href="%1$s" class="musublink">%2$s%3$s<span class="screen-reader-text"> (%4$s)</span></a>',
    19411944                                esc_url( admin_url( 'upload.php' ) ),
     1945                                wp_get_icon( $used_class ? 'core-admin/error' : 'core-admin/media', array( 'size' => 20 ) ),
    19421946                                $text,
    19431947                                /* translators: Hidden accessibility text. */
Note: See TracChangeset for help on using the changeset viewer.