WordPress.org

Make WordPress Core

Opened 3 weeks ago

Closed 6 days ago

#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)

53031.patch (1.2 KB) - added by sabernhardt 3 weeks ago.
update-core-plugins-count.png (4.7 KB) - added by sabernhardt 3 weeks ago.
plugins count
update-core-themes-count.png (7.5 KB) - added by sabernhardt 3 weeks ago.
themes count
53031.1.patch (1.3 KB) - added by sabernhardt 3 weeks ago.
53031.2.diff (2.1 KB) - added by audrasjb 8 days ago.
screencapture-localhost-8888-wordpress-develop-wordpress-develop-build-wp-admin-update-core-php-2021-05-01-00_59_16.png (735.8 KB) - added by audrasjb 8 days ago.
53031.2.diff

Download all attachments as: .zip

Change History (18)

@sabernhardt
3 weeks ago

@sabernhardt
3 weeks ago

plugins count

@sabernhardt
3 weeks ago

themes count

#1 @mukesh27
3 weeks 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 @sabernhardt
3 weeks 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.)

Last edited 3 weeks ago by sabernhardt (previous) (diff)

#3 @davidbaumwald
3 weeks 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>

@sabernhardt
3 weeks ago

#4 @sabernhardt
3 weeks 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 @davidbaumwald
3 weeks ago

@sabernhardt I think leaving the <h2> outside the printf is fine as it's more semantic to the markup than the translatable string.

#6 @audrasjb
8 days ago

  • Milestone changed from Awaiting Review to 5.8

Moving for 5.8 consideration

#7 @joedolson
8 days ago

In 50801:

Toolbar: Remove title attribute on pending updates link.

Remove the title attribute from the link, wrap the link icon and numeric indicator with the aria-hidden attribute, and add a .screen-reader-text span so screen readers hear a link that has relevant context without requiring translators to deal with appended strings. Removes the individual counts of theme and plugin updates from the attribute, as those were already buggy and didn't include translation counts.

Props afercia, Mte90, sabernhardt, audrasjb
Fixes #26562. See #53031.

@audrasjb
8 days ago

#8 follow-up: @audrasjb
8 days 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?

Last edited 7 days ago by audrasjb (previous) (diff)

#9 @sabernhardt
7 days 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 @SergeyBiryukov
6 days 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 @audrasjb
6 days ago

Understood, thank you @SergeyBiryukov for the detailed answer. Let's go with 53031.1.patch then.

#12 @SergeyBiryukov
6 days ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 50803:

Upgrade/Install: Display plugin and theme update counts on WordPress Updates screen.

This restores the information that was previously included in a title attribute tooltip on pending updates link in the toolbar.

Follow-up to [50801].

Props sabernhardt, audrasjb, mukesh27, davidbaumwald.
Fixes #53031.

Note: See TracTickets for help on using tickets.