Changeset 14859
- Timestamp:
- 05/08/2026 08:35:19 PM (2 weeks ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 8 added
- 3 edited
-
cli/class-block-plugin-checker.php (modified) (2 diffs)
-
phpunit.xml (modified) (1 diff)
-
shortcodes/class-block-validator.php (modified) (1 diff)
-
tests/Block_Plugin_Checker_Translation_Test.php (added)
-
tests/fixtures (added)
-
tests/fixtures/block-plugin-register-dir (added)
-
tests/fixtures/block-plugin-register-dir/block.json (added)
-
tests/fixtures/block-plugin-register-dir/plugin.php (added)
-
tests/fixtures/block-plugin-with-textdomain (added)
-
tests/fixtures/block-plugin-with-textdomain/block.json (added)
-
tests/fixtures/block-plugin-with-textdomain/plugin.php (added)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-block-plugin-checker.php
r14773 r14859 431 431 ); 432 432 } else { 433 $all_calls += $php_calls; 433 // Append, not union — per-file calls share numeric keys from 0 so `+=` would drop later files. 434 array_push( $all_calls, ...$php_calls ); 434 435 } 435 436 } … … 1020 1021 1021 1022 /** 1022 * Check that the plugin uses `wp_set_script_translations`. 1023 * Check that the plugin loads script translations. WordPress auto-loads them when a 1024 * block is registered from its `block.json` (via `register_block_type_from_metadata()` 1025 * or `register_block_type( __DIR__ )`) and `block.json` declares a `textdomain`. 1023 1026 */ 1024 1027 function check_for_translation_function() { 1025 1028 $functions = wp_list_pluck( $this->php_function_calls, 0 ); 1026 if ( ! in_array( 'wp_set_script_translations', $functions ) ) { 1027 $this->record_result( 1028 __FUNCTION__, 1029 'warning', 1030 __( 'No translations are loaded for the scripts.', 'wporg-plugins' ), 1031 'wp_set_script_translations' 1032 ); 1033 } 1029 1030 if ( in_array( 'wp_set_script_translations', $functions, true ) ) { 1031 return; 1032 } 1033 1034 $registers_block = in_array( 'register_block_type', $functions, true ) 1035 || in_array( 'register_block_type_from_metadata', $functions, true ); 1036 1037 if ( $registers_block ) { 1038 foreach ( (array) $this->blocks as $block ) { 1039 if ( ! empty( $block->textdomain ) ) { 1040 return; 1041 } 1042 } 1043 } 1044 1045 $this->record_result( 1046 __FUNCTION__, 1047 'warning', 1048 __( 'No translations are loaded for the scripts.', 'wporg-plugins' ), 1049 'wp_set_script_translations' 1050 ); 1034 1051 } 1035 1052 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/phpunit.xml
r14720 r14859 12 12 <exclude>tests/wporg-plugin-api-performance.php</exclude> 13 13 <exclude>tests/api</exclude> 14 <exclude>tests/fixtures</exclude> 14 15 </testsuite> 15 16 </testsuites> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php
r14258 r14859 436 436 return sprintf( 437 437 // translators: %s is the link to the internationalization docs. 438 __( 'Block plugins should use <code>wp_set_script_translations</code> to load translations for each script file. <a href="%s">Learn more about internationalization.</a>', 'wporg-plugins' ),438 __( 'Block plugins should load translations for each script file, either by registering blocks from <code>block.json</code> with a <code>textdomain</code> set, or by calling <code>wp_set_script_translations</code> directly. <a href="%s">Learn more about internationalization.</a>', 'wporg-plugins' ), 439 439 'https://developer.wordpress.org/block-editor/developers/internationalization/' 440 440 );
Note: See TracChangeset
for help on using the changeset viewer.