From de4624ea862225a093a676c5250552bd014c14cd Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Sat, 23 Sep 2023 08:13:04 -0400 Subject: [PATCH 1/3] 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 ) ) ) ); } From 95cb92e9655374b8c81b2a3186e3f15ba9cd2e30 Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Sat, 23 Sep 2023 08:22:06 -0400 Subject: [PATCH 2/3] Fix the problem with array_keys + Changelog --- checks/readme.php | 2 +- readme.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/checks/readme.php b/checks/readme.php index 696155183..0784dd5bb 100644 --- a/checks/readme.php +++ b/checks/readme.php @@ -78,7 +78,7 @@ function check_for_default_text() { function check_for_warnings() { $warnings = $this->readme->warnings ?? []; - $warning_keys = array_keys( $this->readme->warnings ); + $warning_keys = array_keys( $warnings ); $ignored_warnings = [ 'contributor_ignored' ]; diff --git a/readme.txt b/readme.txt index c6d6384d7..677826dde 100644 --- a/readme.txt +++ b/readme.txt @@ -44,7 +44,8 @@ This plugin checker is not perfect, and never will be. It is only a tool to help = [0.2.2] 2023-09-TBD = -* Fix - Remove extra period on the end of the sentence for Phar warning. Props @bordoni, @pixolin. [#275](https://github.com/10up/plugin-check/pull/265) +* Fix - Prevent problems with Readme parser warning related to `contributor_ignored` for when running the check outside of WP.org. Props @bordoni, @dev4press. [#276](https://github.com/10up/plugin-check/pull/276) +* Fix - Remove extra period on the end of the sentence for Phar warning. Props @bordoni, @pixolin. [#275](https://github.com/10up/plugin-check/pull/275) = [0.2.1] 2023-09-22 = From 2bc6f94f5851f93f3dec22c9bb679cfccb54acdb Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Wed, 15 Nov 2023 15:29:23 -0500 Subject: [PATCH 3/3] Make sure we have (array) on the return of the filter. Co-authored-by: Evan Herman --- checks/readme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/readme.php b/checks/readme.php index 0784dd5bb..0fd3e2a9c 100644 --- a/checks/readme.php +++ b/checks/readme.php @@ -91,7 +91,7 @@ function check_for_warnings() { * @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 ); + $ignored_warnings = (array) apply_filters( 'plugin_check_readme_warnings_ignored', $ignored_warnings, $this->readme ); $warning_keys = array_diff( $warning_keys, $ignored_warnings );