Skip to content

Add check for functions ending in __premium_only - #1447

Open
ishitaj34 wants to merge 4 commits into
WordPress:trunkfrom
ishitaj34:fix/issue-1443
Open

Add check for functions ending in __premium_only#1447
ishitaj34 wants to merge 4 commits into
WordPress:trunkfrom
ishitaj34:fix/issue-1443

Conversation

@ishitaj34

@ishitaj34 ishitaj34 commented Aug 21, 2026

Copy link
Copy Markdown

What?

Closes #1443

Adds a static check Premium_Only_Function_Check in the Plugin Repo category to detect PHP function declarations whose names end with the __premium_only suffix.

As a potential future enhancement, this check could be upgraded to a token-aware sniff to ensure occurrences of __premium_only inside PHP comments, docblocks, or string literals are completely ignored.

Why?

WordPress.org plugin directory guidelines do not allow code intended strictly for a paid/pro/premium version to be included in free plugin submissions. Detecting common naming conventions like __premium_only helps authors identify and relocate premium-only code before submitting plugins for review.

How?

  • Created class extending Abstract_File_Check.
  • Uses regex pattern to scan PHP files and report a premium_only_function_found error.
  • Registered the function check in Default_Check_Repository.
  • Added PHPUnit unit test suite and fixture test plugins.

Testing Instructions

  1. Run PHPCS linting and static analysis:
composer lint
composer phpstan
  1. Start test environment stack:
npm run wp-env:start:tests
  1. Run the new unit test suite:
npm run test-php -- --filter=Premium_Only_Function_Check_Tests
  1. Verify that both tests pass - 2 tests, 9 assertions.

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:

  • AI Tool: Gemini CLI
  • Usage: Used to generate boilerplate code for Premium_Only_Function_Check, draft PHPUnit unit test cases, and verify WordPress coding standards compliance. Evaluated architectural trade-offs and manually verified all code, tests, and static analysis outputs.
Open WordPress Playground Preview

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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: ishitaj34 <ishitaj34@git.wordpress.org>
Co-authored-by: monzuralam <monzuralam@git.wordpress.org>

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

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.

Add a check for functions ending in __premium_only

1 participant