Repository navigation
Match wp/wc trademark terms only as whole slug tokens - #1558
anandrajaram21 wants to merge 2 commits into
Conversation
|
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. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 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
wpandwc, 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
What?
Closes #1556
This PR stops the
trademarked_termcheck from flaggingwpandwcwhen 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 plainstrpos()(includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php). The short termswpandwcare inTRADEMARK_SLUGS, so they match inside unrelated words. For example, the plugin nameNinjaDraw - Diagram, Flowchart, Mind Map & Sketching Toolis flagged forwcbecause of "flowchart".How?
This follows the token-match direction suggested in #1556 (comment):
TOKEN_MATCH_TERMSconstant holdingwpandwc.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 callingstrpos()directly. The-prefix terms, the for-use exceptions and the portmanteau checks are unchanged.As agreed in the issue, joined forms like
wcboosterorwptoolsare no longer flagged.Testing Instructions
Trademarks_Check_Testshas a new data-provider test forhas_trademarked_slug():diagram-flowchart-tool,product-showcase,newcomer-guideandcowpea-recipes.wcorwpforwc-extra-fees,extra-fees-wc,extra-wc-fees,wp-helperandwc.wordpressformy-wordpress-tool.test-trademarks-plugin-header-wc-substring(plugin name "Diagram, Flowchart & Showcase Tool"), checks that the name check gives no warnings.npm run test-phpand confirm theTrademarks_Check_Teststests pass.wp plugin check <slug>on a plugin named e.g. "Diagram Flowchart Tool". There should be notrademarked_termwarning. A plugin whose slug starts withwc-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 theflowchart,showcase,newcomerandcowpeaslugs. Thewc/wptoken cases still pass.composer lintandcomposer phpstanare both clean.AI Usage Disclosure
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.