Skip to content

PHPCS sniff to detect if your plugin/theme code is compatible with a wp version (supported range 3.7-current)

License

Notifications You must be signed in to change notification settings

WPCompatibility/WPCompatibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPCompatibility

wpcompatibility is a collection of PHP_CodeSniffer (PHPCS) sniffs designed to check if your WordPress plugin/theme code is compatible with specific WordPress versions.

Table of Contents

Installation:

composer require wpcompatibility/wp-compatibility 

Usage:

Command

# For single wp version
WP_COMPAT_PHPCS_SUPPORTED_VERSIONS='5.0.0' vendor/bin/phpcs --standard=WPCompatibility your-plugin-or-theme-folder/

# To test against multiple wp versions you can separate versions by comma
WP_COMPAT_PHPCS_SUPPORTED_VERSIONS='5.0.1,6.0' vendor/bin/phpcs --standard=WPCompatibility your-plugin-or-theme-folder/

Ruleset File

<rule ref="WPCompatibility.Signature.Function">
    <properties>
        <property name="versions" value="4.3,6.1" />
    </properties>
</rule>

Functions

  • Detect if a wordpress function is present in specific version. For example if you have a plugin file with the below code which is set to be compatible with 5.0, this will throw an error
<?php wp_date(); ?>
Function: wp_date is not available in wordpress version 5.0.0
  • Verify wordpress function signature, if you pass less number of arguments to a wordpress function then it will raise an error.

F_TwK0vbIAAShWP