Repository navigation
Conversation
Use registered core icons and preserve them when comment counts update via AJAX. See https://core.trac.wordpress.org/ticket/66347.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
It's possible for plugin authors to add additional items to the widget using the dashboard_glance_items filter. These items get the dashicons-marker icon.
In this branch they continue to display the dashicon font icon rather than the SVG replacement.
Steps to reproduce:
- Add the following as an mu-plugin (the missing opening and closing
liare intentional as they are added post filter):add_filter( 'dashboard_glance_items', function( $items ) { ob_start(); // Comments. $num_comm = wp_count_comments(); if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { /* translators: %s: Number of comments. */ $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); ?> <a href="edit-comments.php"><?php echo $text; ?></a> </li> <?php $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); /* translators: %s: Number of comments. */ $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n ); ?> <li class="comment-mod-count<?php echo ! $num_comm->moderated ? ' hidden' : ''; ?>"> <a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a> <?php } $items[] = ob_get_clean(); return $items; } );
- Observe that they are still showing the dashicon on this branch.
I think the following will be needed to account for the filter:
- If the plugin includes a wordpress/icon icon that will need to be displayed
- If the plugin is using CSS to display a dashicon, then use the dashicon (this will require
::beforebe displayed by default and then:has( svg )used to hide it.
|
@propsbot add ocean90 |
|
Thanks for pointing this out. I'll fix it. |
|
Noting that I created WordPress/gutenberg#85442 for this use case. |
There was a problem hiding this comment.
Thanks for the PR! I discussed with @jasmussen and we are proposing to use the following dashicons -> SVG icon replacement mapping:
| Dashicon | Suggested SVG | Note |
|---|---|---|
dashicons-marker |
asterisk |
New icon, #85442 (open) adds it to core and core-admin |
dashicons-admin-post |
pin |
Already in core-admin |
dashicons-admin-page |
page |
Already in core-admin |
dashicons-admin-comments |
comment |
Already in core-admin |
dashicons-format-chat |
post-comments |
Needs to be added to core-admin (not in any collection yet) |
dashicons-admin-media |
media |
Already in core-admin |
dashicons-dismiss |
error |
Needs to be promoted from core to core-admin |
dashicons-info |
info |
Needs to be promoted from core to core-admin |
There are two issues:
- We need to add a new icon, and to promote several icons to
core-admin/. @t-hamano / @peterwilsoncc, is it still doable in Beta 1? - It seems there are currently no good way to insert the new
asteriskicon for plugin-added items, viawp_get_icon(). At the best case, we need to use CSS mask and copy-paste theasteriskSVG. Happy to be proven wrong. But it seems we need a more generic way in the existingdashboard_glance_itemsfilter, so that plugins can add proper icons (falling back toasterisk). For this functionality, I think it's clear that it will be after 7.2.
In principle, enhancements can't be committed after Beta 1, but I think it depends on the situation. Since #65089 landed in 7.2, the inconsistency with the At a Glance widget was introduced in this release, so I think it's reasonable to treat this as a follow-up. In my opinion, we should avoid extending APIs at this stage, such as allowing properties that currently accept a Dashicons class to also accept an SVG icon name. However, I think adding new icons and promoting existing ones to the |
|
I will note: what was a big unblocking factor for more accessible and hopefully legible icons across the admin, was the main effort to update icons in the navigation and adminbar. The work does not have to stop here, but we also don't have to get everything right in a single release. It's going to be a journey: if we update glance icons in 7.2, that's nice. If we don't, there's going to be another train. |
Makes sense. Then it seems we need to backport these PRs:
, then wait until we sync them for Beta 2, and only then can we use the icons in this PR. Let me know if I understood incorrectly. |
|
Thanks, @peterwilsoncc and @fushar! I used The I haven't updated the generated icon files, so for now, the "Comments in moderation" item, the storage-over-quota item, and the search engines notice will continue using their existing Dashicons. Once the SVGs are available, the CSS fallbacks will be hidden automatically using @t-hamano, could these two PRs be included in the Beta 2 sync? |
Replace the Dashicons in the “At a Glance” dashboard widget with registered core SVG icons. Preserve warning colors, plugin-added icon fallbacks, and SVG icons when comment counts update via AJAX.
Trac ticket: https://core.trac.wordpress.org/ticket/66347
Screenshots
Testing
Use of AI Tools
AI assistance: Yes
Tool(s): OpenAI Codex
Used for: Icons lookup, PR Desciption, and replacing the icons.