#53031 closed enhancement (fixed)
Display counts for available plugin and theme updates on update-core.php
Reported by: | sabernhardt | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | minor | Version: | |
Component: | Upgrade/Install | Keywords: | has-patch has-screenshots |
Focuses: | ui, administration, ui-copy | Cc: |
Description
I would like to display counts for plugin and theme updates on the Updates screen within the context of those two sections.
Currently, the admin toolbar uses a title attribute tooltip on most screens to display those counts on mouseover. I already suggested removing that tooltip from all admin screens (and the front end) in ticket:26562, but I like knowing the numbers.
Attachments (6)
Change History (19)
#1
@
3 years ago
- Keywords has-patch added
Hi there!
53031.patch patch looks good to me.
Can we change $plugins_available
to $plugins_count
and $themes_available
to $themes_count
for better understanding?
#2
@
3 years ago
$plugins_count
should be better than my variable name, and it would reflect the naming in privacy tools.
(I used that span
instead of adding it to the translated string, though many strings include it within list table filter links.)
#3
@
3 years ago
@sabernhardt Great work so far. If you're reworking the patch, could we tidy things up a bit with something like...
<h2> <?php printf( '%s <span class="count">(%d)</span>' __( 'Plugins' ), $plugins_available ); ?> </h2>
#4
@
3 years ago
Thank you both for the quick feedback.
The variable names include "count" and the PHP combines heading text with the count. I also used the number format function in case it's necessary.
Would it be easier to read the printf
with the heading tag inside there, too?
$themes_count = count( $themes ); printf( '<h2>%s <span class="count">(%d)</span></h2>', __( 'Themes' ), number_format_i18n( $themes_count ) ); ?>
#5
@
3 years ago
@sabernhardt I think leaving the <h2>
outside the printf
is fine as it's more semantic to the markup than the translatable string.
#8
follow-up:
↓ 10
@
3 years ago
- Focuses ui-copy added
- Keywords has-screenshots added
Hey there!
53031.2.diff
suggests the following changes:
- move the whole string into the gettext function so translators are able to reverse the order
- use a pluralized translation string so translators are able to use a different translation depending on the number of items
- also display the number of translation packages that are going to be updated (I'm not 100% sure this one is needed, but… why not)
What do you think about this proposal?
#9
@
3 years ago
No objections from me :)
I chose the simpler way without new translations, though it likely is better to add them.
Showing the number of translation updates available might help to have an idea how much time the process will take (especially on a slow server). That also makes the headings more consistent.
#10
in reply to:
↑ 8
@
3 years ago
Replying to audrasjb:
53031.2.diff
suggests the following changes:
- move the whole string into the gettext function so translators are able to reverse the order
Just noting that for RTL translations there is no need to reverse the order in cases like this, text direction takes care of that.
- use a pluralized translation string so translators are able to use a different translation depending on the number of items
Also noting that this is not as straightforward as it seems, there's a note in the plugin i18n handbook:
Note that some languages use the singular form for other numbers (e.g. 21, 31 and so on, much like ’21st’, ’31st’ in English). If you would like to special case the singular, check for it specifically:
if ( 1 === $count ) { printf( esc_html__( 'Last thing!', 'my-text-domain' ), $count ); } else { printf( esc_html( _n( '%d thing.', '%d things.', $count, 'my-text-domain' ) ), $count ); }
See the discussions in #28502, #33239, #34127, #34307, #34308 for more context.
- also display the number of translation packages that are going to be updated (I'm not 100% sure this one is needed, but… why not)
No strong objections here, but it looks a bit weird to see the number if we're not listing the updates themselves.
Not listing them was intentional decision at the time, as they are generally installed automatically under the hood, e.g. along with a plugin or theme update. Related: #28133, #28571, #32270, #34907.
So going with 53031.1.patch for now would be my preference here.
#11
@
3 years ago
Understood, thank you @SergeyBiryukov for the detailed answer. Let's go with 53031.1.patch then.
#12
@
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 50803:
plugins count