diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index c08e955b8..cf181fa03 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 allowed acronyms of trademarks. + * + * @since 1.3.0 + * + * @var string[] + */ + const ALLOWED_ACRONYMS = 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::ALLOWED_ACRONYMS, true ) + ) { + // 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 , 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, '-' ) ) + ); } 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::ALLOWED_ACRONYMS, 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 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, '-' ) ) + ); } 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 , 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, 'test-trademarks-plugin-header-woocommerce-string-for-woocommerce/load.php',