Make WordPress Core

Changeset 65850


Ignore:
Timestamp:
12/01/2026 01:38:01 PM (2 hours ago)
Author:
audrasjb
Message:

Upgrade/Install: Count each translation update in the update counts.

The Updates badge in the admin menu and the admin bar always counted translation updates as "1", even when there were more. Since 7.2, the Updates screen lists each translation update and shows the real number in the heading, for example "Translations (3)", so the badge and the screen no longer match.

This changeset ensures each available translation update is taken into account, the same way plugin and theme updates are counted.

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

Follow-up to [65226].

Props sainathpoojary, wildworks, krupalpanchal, audrasjb.
Fixes #66806.
See #42281.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r65226 r65850  
    11131113        }
    11141114
    1115         if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) {
    1116                 $counts['translations'] = 1;
     1115        if ( $core || $plugins || $themes ) {
     1116                $counts['translations'] = count( wp_get_translation_updates() );
    11171117        }
    11181118
  • trunk/tests/phpunit/tests/functions/wpGetUpdateData.php

    r65388 r65850  
    300300
    301301        /**
    302          * Tests that translation updates in any update transient are counted once.
    303          *
    304          * @ticket 65819
     302         * Tests that each translation update in any update transient is counted.
     303         *
     304         * @ticket 65819
     305         * @ticket 66806
    305306         *
    306307         * @dataProvider data_update_transients
    … …  
    308309         * @param string $transient The update transient holding the translations.
    309310         */
    310         public function test_should_count_translation_updates_once( $transient ) {
     311        public function test_should_count_each_translation_update( $transient ) {
    311312                wp_set_current_user( self::$admin_id );
    312313
    … …  
    323324                $data = wp_get_update_data();
    324325
    325                 $this->assertSame( 1, $data['counts']['translations'], 'Translation updates should be counted once.' );
     326                $this->assertSame( 2, $data['counts']['translations'], 'Each translation update should be counted.' );
    326327                $this->assertSame( 'Translation Updates', $data['title'], 'The title should mention translation updates.' );
     328        }
     329
     330        /**
     331         * Tests that translation updates across all update transients are counted together.
     332         *
     333         * @ticket 66806
     334         */
     335        public function test_should_count_translation_updates_across_transients() {
     336                wp_set_current_user( self::$admin_id );
     337
     338                foreach ( self::$transients as $transient ) {
     339                        set_site_transient(
     340                                $transient,
     341                                (object) array(
     342                                        'translations' => array(
     343                                                array( 'language' => 'de_DE' ),
     344                                        ),
     345                                )
     346                        );
     347                }
     348
     349                $this->assertSame( 3, wp_get_update_data()['counts']['translations'] );
    327350        }
    328351
Note: See TracChangeset for help on using the changeset viewer.