Skip to content

Commit

Permalink
tradermarks check with acronym allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Sep 29, 2024
1 parent 6418d8d commit 1a87845
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
37 changes: 36 additions & 1 deletion includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-',
Expand All @@ -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.
*
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Plugin Name: WP Example String
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Trademarks check.
* Requires at least: 6.0
* Requires PHP: 5.6
* Version: 1.0.0
* Author: WordPress Review Team
* Author URI: https://make.wordpress.org/plugins/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: test-trademarks-plugin-header-acronym
*
* @package test-trademarks-plugin-header-acronym
*/
6 changes: 6 additions & 0 deletions tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ 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(
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',
Expand Down

0 comments on commit 1a87845

Please sign in to comment.