Skip to content

Commit

Permalink
Merge pull request #680 from WordPress/464-allow-wp-prefixes-on-plugins
Browse files Browse the repository at this point in the history
Added Trademarks check with acronym allowed
  • Loading branch information
ernilambar authored Nov 14, 2024
2 parents d6551d0 + 7be1dc4 commit 608225a
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 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.
*
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::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(
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::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(
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 , 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',
Expand Down

0 comments on commit 608225a

Please sign in to comment.