diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 177d5082..0c9dbd28 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -95,6 +95,25 @@ public function run( Check_Result $result ) { '', 6 ); + } else { + $potential_slug = sanitize_title_with_dashes( str_replace( '_', '-', preg_replace( '/[^a-z0-9 _.-]/i', '', remove_accents( $plugin_header['Name'] ) ) ) ); + + if ( empty( $potential_slug ) ) { + $this->add_result_error_for_file( + $result, + sprintf( + /* translators: %s: plugin header field */ + __( 'The "%s" header in the plugin file is not valid. It may only contain latin letters (A-z), numbers, spaces, and hyphens.', 'plugin-check' ), + esc_html( $labels['Name'] ) + ), + 'plugin_header_unsupported_plugin_name', + $plugin_main_file, + 0, + 0, + 'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields', + 7 + ); + } } } diff --git a/tests/behat/features/plugin-check.feature b/tests/behat/features/plugin-check.feature index c39dcd77..ebb7d190 100644 --- a/tests/behat/features/plugin-check.feature +++ b/tests/behat/features/plugin-check.feature @@ -719,3 +719,27 @@ Feature: Test that the WP-CLI command works. """ readme_invalid_contributors """ + + Scenario: Check unsupported plugin name in plugin header field. + Given a WP install with the Plugin Check plugin + And a wp-content/plugins/foo-sample/foo-sample.php file: + """ +