From de4624ea862225a093a676c5250552bd014c14cd Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Sat, 23 Sep 2023 08:13:04 -0400 Subject: [PATCH] Create a way to remove certain readme warnings, contributors_ignored is specifically something we need on WP.org but other users will alwayss have it show up. --- checks/readme.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/checks/readme.php b/checks/readme.php index f9b7a8383..696155183 100644 --- a/checks/readme.php +++ b/checks/readme.php @@ -1,6 +1,7 @@ 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 ) ) ) ); }