Summary
Plugin Check does not currently flag PHP function declarations whose names end in __premium_only.
This naming pattern is often used to mark code that belongs to a paid/pro/premium version of a plugin. If this code is included in a WordPress.org plugin submission, Plugin Check should report it so authors can remove or relocate the premium-only code before review.
Problem
When a plugin contains functions such as:
function my_plugin_register_settings__premium_only() {
register_setting( 'my_plugin_settings', 'my_plugin_enabled' );
}
function my_plugin_admin_notice__premium_only() {
echo '<div class="notice notice-info"><p>Premium-only feature enabled.</p></div>';
}
Plugin Check currently does not identify these declarations as potential premium/pro-only code.
Expected behavior
Plugin Check should flag function declarations ending in __premium_only, for example:
function example_feature__premium_only() {}
Suggested result:
- Type: Error, or warning if the project prefers a lower severity first
- Category: Plugin Repo
- Code:
PremiumOnlyFunction.Found
- Message:
Function declarations ending in __premium_only look like premium/pro-only code and should not be included in a WordPress.org plugin.
Current behavior
Plugin Check completes without reporting the __premium_only function names.
Why this matters
WordPress.org plugins should not include code intended only for a paid/pro/premium version. Detecting common naming conventions like __premium_only would help catch this issue earlier and make Plugin Check more useful before plugin submission.
Reproduction steps
- Create a test plugin with this file:
<?php
/**
* Plugin Name: Premium Only Function Test
* Description: Test plugin containing functions named with the __premium_only suffix.
* Author: Monzur Alam
* Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function poft_register_settings__premium_only() {
register_setting( 'poft_settings', 'poft_enabled' );
}
function poft_admin_notice__premium_only() {
echo '<div class="notice notice-info"><p>Premium-only test notice.</p></div>';
}
- Run Plugin Check against the test plugin.
- Observe that no issue is reported for the
__premium_only function declarations.
Proposed implementation
Add a static file check that scans PHP files for function declarations ending in __premium_only.
Possible regex:
/\bfunction\s+[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*__premium_only\s*\(/
The check could extend Plugin Check's existing file-check infrastructure:
WordPress\Plugin_Check\Checker\Checks\Abstract_File_Check
and register under the existing Plugin Repo category.
Summary
Plugin Check does not currently flag PHP function declarations whose names end in
__premium_only.This naming pattern is often used to mark code that belongs to a paid/pro/premium version of a plugin. If this code is included in a WordPress.org plugin submission, Plugin Check should report it so authors can remove or relocate the premium-only code before review.
Problem
When a plugin contains functions such as:
Plugin Check currently does not identify these declarations as potential premium/pro-only code.
Expected behavior
Plugin Check should flag function declarations ending in
__premium_only, for example:Suggested result:
PremiumOnlyFunction.FoundFunction declarations ending in __premium_only look like premium/pro-only code and should not be included in a WordPress.org plugin.Current behavior
Plugin Check completes without reporting the
__premium_onlyfunction names.Why this matters
WordPress.org plugins should not include code intended only for a paid/pro/premium version. Detecting common naming conventions like
__premium_onlywould help catch this issue earlier and make Plugin Check more useful before plugin submission.Reproduction steps
__premium_onlyfunction declarations.Proposed implementation
Add a static file check that scans PHP files for function declarations ending in
__premium_only.Possible regex:
The check could extend Plugin Check's existing file-check infrastructure:
and register under the existing
Plugin Repocategory.