Repository navigation
Commit 3af54e5
committed
I18N: Print translations for the script modules that scripts depend on.
`WP_Script_Modules::print_script_module_translations()` only covered the enqueued script modules and their dependencies. A script module that only a script imports, declared in the script's `module_dependencies`, is added to the import map and loads, but its translations were never printed, so its strings showed untranslated.
The method now covers the enqueued script modules and the script modules in the import map, which includes the script module dependencies of scripts and their dependencies. `WP_Script_Modules::print_script_module_data()` already covered these script modules, and both methods now get them from the same private `get_loadable_script_module_ids()` method, which sorts them with `get_sorted_dependencies()`. This way both methods always cover the same script modules, in the same order, with dependencies before the script modules that depend on them. A script module that is both enqueued and imported by a script gets its translations printed once.
Since the import map is now built three times per page, a missing script module dependency of a script triggers the `_doing_it_wrong()` notice once per script.
Fixes #66591.1 parent 31a6fb4 commit 3af54e5
2 files changed
Lines changed: 360 additions & 17 deletions
File tree
- src/wp-includes
- tests/phpunit/tests/script-modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
| |||
367 | 379 | | |
368 | 380 | | |
369 | 381 | | |
370 | | - | |
| 382 | + | |
| 383 | + | |
371 | 384 | | |
372 | 385 | | |
373 | 386 | | |
| |||
379 | 392 | | |
380 | 393 | | |
381 | 394 | | |
| 395 | + | |
| 396 | + | |
382 | 397 | | |
383 | 398 | | |
384 | | - | |
385 | | - | |
| 399 | + | |
386 | 400 | | |
387 | 401 | | |
388 | 402 | | |
| |||
684 | 698 | | |
685 | 699 | | |
686 | 700 | | |
687 | | - | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
688 | 705 | | |
689 | 706 | | |
690 | 707 | | |
| |||
696 | 713 | | |
697 | 714 | | |
698 | 715 | | |
| 716 | + | |
699 | 717 | | |
700 | 718 | | |
701 | 719 | | |
| |||
723 | 741 | | |
724 | 742 | | |
725 | 743 | | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
726 | 765 | | |
727 | 766 | | |
728 | 767 | | |
| |||
1014 | 1053 | | |
1015 | 1054 | | |
1016 | 1055 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1029 | 1060 | | |
1030 | 1061 | | |
1031 | | - | |
| 1062 | + | |
1032 | 1063 | | |
1033 | 1064 | | |
1034 | 1065 | | |
| |||
0 commit comments