Make WordPress Core


Ignore:
Timestamp:
10/02/2024 01:42:11 PM (2 months ago)
Author:
swissspidy
Message:

I18N: Do not load translations directly in load_*_textdomain.

In [59127], _doing_it_wrong warnings were added if plugins or themes load translations too early, either through a manual function call or just-in-time loading.

Because many plugins and themes still manually call load_plugin_textdomain(), load_theme_textdomain() or load_muplugin_textdomain(), even though they don't have to anymore, that caused a lot of warnings.

With this new approach, these functions merely register the translations path in the existing WP_Textdomain_Registry and do not immediately try to load the translations anymore. The loading is all handled by the just-in-time functionality.

This way, warnings will only be emitted if triggering the just-in-time loading too early, greatly improving the developer experience and to a degree also performance.

Props swissspidy, sergeybiryukov, mukesh27.
See #44937.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    r58328 r59157  
    583583        $result   = $response->get_data();
    584584        $this->assertArrayHasKey( 'tags', $result[0] );
    585         $this->assertSame( array( 'holiday', 'custom-menu' ), $result[0]['tags']['raw'] );
    586         $this->assertSame( 'holiday, custom-menu', $result[0]['tags']['rendered'] );
     585        $this->assertSame( array( 'Holiday', 'custom-menu' ), $result[0]['tags']['raw'] );
     586        $this->assertSame( 'Holiday, custom-menu', $result[0]['tags']['rendered'] );
    587587    }
    588588
Note: See TracChangeset for help on using the changeset viewer.