From 1a87845eb3dedb059f8c0c070a40eeda53e5b525 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sun, 29 Sep 2024 12:02:38 +0200 Subject: [PATCH 01/11] tradermarks check with acronym allowed --- .../Checks/Plugin_Repo/Trademarks_Check.php | 37 ++++++++++++++++++- .../load.php | 16 ++++++++ .../Checker/Checks/Trademarks_Check_Tests.php | 6 +++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 16de65d2e..d092661e2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -137,7 +137,8 @@ class Trademarks_Check extends Abstract_File_Check { 'wordpress', 'wordpess', 'wpress', - 'wp-', + 'wp', // it's allowed, but shows a warning. + 'wc', // it's allowed, but shows a warning. 'wp-mail-smtp-', 'yandex-', 'yahoo-', @@ -146,6 +147,18 @@ class Trademarks_Check extends Abstract_File_Check { 'you-tube-', ); + /** + * Lists of trademarks that are allowed but shows in acronym. + * + * @since n.e.x.t. + * + * @var string[] + */ + const FOR_USE_ACRONYM = array( + 'wp', + 'wc', + ); + /** * Lists of trademarks that are allowed as 'for-whatever' ONLY. * @@ -348,6 +361,17 @@ private function validate_name_has_no_trademarks( $plugin_name ) { esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); + } elseif ( + trim( $check, '-' ) === $check + && in_array( $check, self::FOR_USE_ACRONYM, true ) + ) { + // Trademarks that are allowed to use with Acronym. + $message = sprintf( + /* translators: 1: plugin slug, 2: found trademarked term */ + __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + esc_html( $plugin_name ), + esc_html( trim( $check, '-' ) ) + ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( @@ -395,6 +419,17 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); + } elseif ( + trim( $check, '-' ) === $check + && in_array( $check, self::FOR_USE_ACRONYM, true ) + ) { + // Trademarks that are allowed to use with Acronym. + $message = sprintf( + /* translators: 1: plugin slug, 2: found trademarked term */ + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within in your plugin slug, unless your plugin name will not change to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + esc_html( $plugin_slug ), + esc_html( trim( $check, '-' ) ) + ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( diff --git a/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php b/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php new file mode 100644 index 000000000..ad7aa092f --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php @@ -0,0 +1,16 @@ + array( + Trademarks_Check::TYPE_NAME, + 'test-trademarks-plugin-header-acronym/load.php', + 'load.php', + 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', + ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-woocommerce-string-for-woocommerce/load.php', From 5ae0f53b61cc2ebdd59879dc7ac400432b2b0630 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sun, 29 Sep 2024 12:07:10 +0200 Subject: [PATCH 02/11] phplint --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 2dd8b1903..787c721fe 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -75,7 +75,7 @@ public function data_trademarks_check() { 'load.php', 'The plugin name includes a restricted term. Your chosen plugin name - "WooCommerce Example String" - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', ), - 'Plugin headers - WP Example String' => array( + 'Plugin headers - WP Example String' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', From 09aef008f20ad9cf588ad4234684a8944414e203 Mon Sep 17 00:00:00 2001 From: David Perez Date: Mon, 30 Sep 2024 08:17:44 +0200 Subject: [PATCH 03/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Nilambar Sharma --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index d092661e2..f8c00d9a9 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -150,7 +150,7 @@ class Trademarks_Check extends Abstract_File_Check { /** * Lists of trademarks that are allowed but shows in acronym. * - * @since n.e.x.t. + * @since 1.2.0 * * @var string[] */ From 1af79deda41c6c623c8d673b7469516f1afff46e Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:22 +0200 Subject: [PATCH 04/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index f8c00d9a9..2303b9ffd 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -365,7 +365,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { trim( $check, '-' ) === $check && in_array( $check, self::FOR_USE_ACRONYM, true ) ) { - // Trademarks that are allowed to use with Acronym. + // Trademarks that are allowed to use as an acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), From 0428d7a56ed9c4240bc8029f6af5a7f4bb71d278 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:33 +0200 Subject: [PATCH 05/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 2303b9ffd..953f7edec 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -368,7 +368,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { // Trademarks that are allowed to use as an acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); From c92dd13e5c70caf49501ca900a9624e86f8d7f28 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:43 +0200 Subject: [PATCH 06/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 953f7edec..35f064d52 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -426,7 +426,7 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { // Trademarks that are allowed to use with Acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within in your plugin slug, unless your plugin name will not change to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within the plugin slug, as long as you don\'t use the full name in the plugin name. For example: You can use WP but not WordPress.', 'plugin-check' ), esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); From 5a73db811c96ec8d2d39cce8ff5915f2ce8c39f6 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:42:03 +0200 Subject: [PATCH 07/11] Update tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php Co-authored-by: Pascal Birchler --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 787c721fe..2e8797af0 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -79,7 +79,7 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', - 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', + 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, From a323a1eabdd836105e6471f9e4740133b5d1ba3c Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:43:21 +0200 Subject: [PATCH 08/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 35f064d52..cfd2f37b5 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -148,7 +148,7 @@ class Trademarks_Check extends Abstract_File_Check { ); /** - * Lists of trademarks that are allowed but shows in acronym. + * Lists of allowed acronyms of trademarks. * * @since 1.2.0 * From b21361d37957522463acbfb335fadccba0fe5f13 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Tue, 1 Oct 2024 10:45:02 +0200 Subject: [PATCH 09/11] changed name constant --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index cfd2f37b5..296cb27e2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -154,7 +154,7 @@ class Trademarks_Check extends Abstract_File_Check { * * @var string[] */ - const FOR_USE_ACRONYM = array( + const ALLOWED_ACRONYMS = array( 'wp', 'wc', ); @@ -363,7 +363,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { ); } elseif ( trim( $check, '-' ) === $check - && in_array( $check, self::FOR_USE_ACRONYM, true ) + && in_array( $check, self::ALLOWED_ACRONYMS, true ) ) { // Trademarks that are allowed to use as an acronym. $message = sprintf( @@ -421,7 +421,7 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { ); } elseif ( trim( $check, '-' ) === $check - && in_array( $check, self::FOR_USE_ACRONYM, true ) + && in_array( $check, self::ALLOWED_ACRONYMS, true ) ) { // Trademarks that are allowed to use with Acronym. $message = sprintf( From 9c107c2537ab7a86bb4792fb4963db7c42d55bf6 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Tue, 1 Oct 2024 22:13:50 +0200 Subject: [PATCH 10/11] fix tests --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 2e8797af0..1470b2d3b 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -79,7 +79,7 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', - 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', + 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, From 7be1dc4a9a66bba7fae667b6109c0d7cee533c1e Mon Sep 17 00:00:00 2001 From: David Perez Date: Wed, 13 Nov 2024 22:19:54 +0100 Subject: [PATCH 11/11] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Nilambar Sharma --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index afa03fb4a..cf181fa03 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -150,7 +150,7 @@ class Trademarks_Check extends Abstract_File_Check { /** * Lists of allowed acronyms of trademarks. * - * @since 1.2.0 + * @since 1.3.0 * * @var string[] */