Skip to content

Commit

Permalink
Add check for unsupported plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Dec 10, 2024
1 parent fb2aaae commit 17dbf42
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}

Expand Down

0 comments on commit 17dbf42

Please sign in to comment.