Skip to content

Commit

Permalink
Create a way to remove certain readme warnings, contributors_ignored …
Browse files Browse the repository at this point in the history
…is specifically something we need on WP.org but other users will alwayss have it show up.
  • Loading branch information
bordoni committed Sep 23, 2023
1 parent acdbafc commit de4624e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions checks/readme.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace WordPressdotorg\Plugin_Check\Checks;
use WordPressdotorg\Plugin_Check\{Error, Guideline_Violation, Message, Notice, Warning};
use WordPressdotorg\Plugin_Directory\Readme\Parser;

class Readme extends Check_Base {
/**
Expand Down Expand Up @@ -76,13 +77,31 @@ function check_for_default_text() {
}

function check_for_warnings() {
if ( ! empty( $this->readme->warnings ) ) {
$warnings = $this->readme->warnings ?? [];
$warning_keys = array_keys( $this->readme->warnings );
$ignored_warnings = [
'contributor_ignored'
];

/**
* Filter the list of ignored readme parser warnings.
*
* @since 0.2.2
*
* @param array $ignored_warnings Array of ignored warning keys.
* @param Parser $readme The readme object.
*/
$ignored_warnings = apply_filters( 'plugin_check_readme_warnings_ignored', $ignored_warnings, $this->readme );

$warning_keys = array_diff( $warning_keys, $ignored_warnings );

if ( ! empty( $warning_keys ) ) {
return new Warning(
'readme_parser_warnings',
sprintf(
/* translators: %1$s: list of warnings */
__( 'The following readme parser warnings were detected: %1$s', 'plugin-check' ),
esc_html( implode( ', ', array_keys( $this->readme->warnings ) ) )
esc_html( implode( ', ', $warning_keys ) )
)
);
}
Expand Down

0 comments on commit de4624e

Please sign in to comment.