@@ -411,25 +411,43 @@ public function run( Check_Result $result ) {
411
411
412
412
if ( ! $ result ->plugin ()->is_single_file_plugin () ) {
413
413
if ( ! empty ( $ plugin_header ['TextDomain ' ] ) ) {
414
- $ plugin_slug = $ result ->plugin ()->slug ();
415
-
416
- if ( $ plugin_slug !== $ plugin_header ['TextDomain ' ] ) {
417
- $ this ->add_result_warning_for_file (
414
+ if ( ! preg_match ( '/^[a-z0-9]+(?:-[a-z0-9]+)*$/ ' , $ plugin_header ['TextDomain ' ] ) ) {
415
+ $ this ->add_result_error_for_file (
418
416
$ result ,
419
417
sprintf (
420
- /* translators: 1: plugin header field, 2: plugin header text domain, 3: plugin slug */
421
- __ ( 'The "%1$s" header in the plugin file does not match the slug . Found "%2$s", expected "%3 $s". ' , 'plugin-check ' ),
418
+ /* translators: 1: plugin header field, 2: text domain */
419
+ __ ( 'The "%1$s" header in the plugin file should only contain lowercase letters, numbers, and hyphens . Found "%2$s". ' , 'plugin-check ' ),
422
420
esc_html ( $ labels ['TextDomain ' ] ),
423
- esc_html ( $ plugin_header ['TextDomain ' ] ),
424
- esc_html ( $ plugin_slug )
421
+ esc_html ( $ plugin_header ['TextDomain ' ] )
425
422
),
426
- 'textdomain_mismatch ' ,
423
+ 'textdomain_invalid_format ' ,
427
424
$ plugin_main_file ,
428
425
0 ,
429
426
0 ,
430
- 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/ ' ,
431
- 6
427
+ 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains ' ,
428
+ 7
432
429
);
430
+ } else {
431
+ $ plugin_slug = $ result ->plugin ()->slug ();
432
+
433
+ if ( $ plugin_slug !== $ plugin_header ['TextDomain ' ] ) {
434
+ $ this ->add_result_warning_for_file (
435
+ $ result ,
436
+ sprintf (
437
+ /* translators: 1: plugin header field, 2: plugin header text domain, 3: plugin slug */
438
+ __ ( 'The "%1$s" header in the plugin file does not match the slug. Found "%2$s", expected "%3$s". ' , 'plugin-check ' ),
439
+ esc_html ( $ labels ['TextDomain ' ] ),
440
+ esc_html ( $ plugin_header ['TextDomain ' ] ),
441
+ esc_html ( $ plugin_slug )
442
+ ),
443
+ 'textdomain_mismatch ' ,
444
+ $ plugin_main_file ,
445
+ 0 ,
446
+ 0 ,
447
+ 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/ ' ,
448
+ 6
449
+ );
450
+ }
433
451
}
434
452
}
435
453
0 commit comments