Skip to content

Match wp/wc trademark terms only as whole slug tokens - #1558

Open
anandrajaram21 wants to merge 2 commits into
WordPress:trunkfrom
anandrajaram21:fix/1556-trademarked-term-token-match
Open

anandrajaram21 wants to merge 2 commits into
WordPress:trunkfrom
anandrajaram21:fix/1556-trademarked-term-token-match

Conversation

@anandrajaram21

@anandrajaram21 anandrajaram21 commented Nov 27, 2026 •

Copy link
Copy Markdown

What?

Closes #1556

This PR stops the trademarked_term check from flagging wp and wc when they only show up inside ordinary words like "flowchart", "showcase", "newcomer" or "cowpea".

Why?

has_trademarked_slug() matches every trademark term that doesn't end in - with a plain strpos() (includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php). The short terms wp and wc are in TRADEMARK_SLUGS, so they match inside unrelated words. For example, the plugin name NinjaDraw - Diagram, Flowchart, Mind Map & Sketching Tool is flagged for wc because of "flowchart".

How?

This follows the token-match direction suggested in #1556 (comment):

  • I added a TOKEN_MATCH_TERMS constant holding wp and wc.
  • I added a private helper, slug_contains_term(). For those two terms it uses /(?:^|-)term(?:-|$)/, so they only match as whole dash-delimited tokens. All other terms keep the existing substring match.
  • has_trademarked_slug() now calls the helper instead of calling strpos() directly. The - prefix terms, the for-use exceptions and the portmanteau checks are unchanged.

As agreed in the issue, joined forms like wcbooster or wptools are no longer flagged.

Testing Instructions

  • Trademarks_Check_Tests has a new data-provider test for has_trademarked_slug():
    • It expects no match for diagram-flowchart-tool, product-showcase, newcomer-guide and cowpea-recipes.
    • It expects wc or wp for wc-extra-fees, extra-fees-wc, extra-wc-fees, wp-helper and wc.
    • It expects wordpress for my-wordpress-tool.
  • A new fixture plugin, test-trademarks-plugin-header-wc-substring (plugin name "Diagram, Flowchart & Showcase Tool"), checks that the name check gives no warnings.
  • Run npm run test-php and confirm the Trademarks_Check_Tests tests pass.
  • To check by hand, run wp plugin check <slug> on a plugin named e.g. "Diagram Flowchart Tool". There should be no trademarked_term warning. A plugin whose slug starts with wc- should still get one.

I ran the full PHPUnit suite locally in wp-env (PHP 7.4). With this change it passes (611 tests, 1736 assertions). With trunk's Trademarks_Check.php (b9b1081) and the new tests, exactly the 5 regression cases fail: the name-header test and the flowchart, showcase, newcomer and cowpea slugs. The wc/wp token cases still pass. composer lint and composer phpstan are both clean.

AI Usage Disclosure

  • This PR was created without the help of AI tools
  • This PR includes AI-assisted code or content

If AI tools were used, please describe how they were used:
I used Claude Code to help reproduce the issue, implement the fix and tests, and draft this description. I reviewed and verified the changes myself.

Open WordPress Playground Preview

@github-actions

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: anandrajaram21 <altf4falt@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>
Co-authored-by: yalogica <yalogica@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@anandrajaram21
anandrajaram21 marked this pull request as draft November 27, 2026 17:16
@anandrajaram21
anandrajaram21 marked this pull request as ready for review November 27, 2026 18:11
@ernilambar
ernilambar requested a balanced review from Copilot November 28, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the trademark-matching update intended to reduce false positives.

No open issues 🎉

What changed in this PR

This PR addresses #1556 by limiting wp and wc trademark matches to whole dash-delimited slug tokens, avoiding false positives in words such as “flowchart” and “showcase.”

Changes:

  • Adds token-aware matching for wp and wc, preserving substring matching for other terms.
  • Adds regression tests for embedded short terms and valid trademark tokens.
  • Adds a fixture plugin to verify that ordinary words in plugin names produce no trademark warnings.
File Description
tests/​phpunit/​tests/​Checker/​Checks/​Trademarks_Check_Tests.php Adds slug-matching and plugin-name regression tests.
tests/​phpunit/​testdata/​plugins/​test-trademarks-plugin-header-wc-substring/​load.php Provides a plugin-name fixture containing “Flowchart” and “Showcase.”
includes/​Checker/​Checks/​Plugin_Repo/​Trademarks_Check.php Adds whole-token matching for wp and wc.

Review effort: Balanced

@ernilambar ernilambar added this to the 2.3 milestone Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive trademarked_term warning for "wc" inside the word "Flowchart"

3 participants