- Notifications
You must be signed in to change notification settings - Fork1
PHP Coding Standards used by the WPForms team.
License
awesomemotive/wpforms-phpcs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Maintainers: The WPForms team
License: GPLv2 any later version.
License URI:http://www.gnu.org/licenses/gpl-2.0.html
WPForms coding standards are based on theWordPress Coding Standards and thePHPCompatibility Coding Standards and help create strict and high-quality code.
composer config repositories.repo-name vcs https://github.com/awesomemotive/wpforms-phpcs.gitcomposer require awesomemotive/wpforms-phpcs --dev
Create the.phpcs.xml
orphpcs.xml
file at the root of your project:
<?xml version="1.0"?><rulesetname="WPForms CS"><description>The WPForms coding standard.</description><exclude-pattern>\vendor/*</exclude-pattern><exclude-pattern>\.github/*</exclude-pattern><configname="testVersion"value="5.6-"/><configname="multi_domains"value="true"/><configname="minimum_supported_wp_version"value="5.2"/><ruleref="WPForms"/><ruleref="WPForms.PHP.ValidateDomain"><properties><propertyname="wpforms-lite"value="wpforms"/><propertyname="wpforms"value="wpforms/pro/,wpforms/src/Pro/"/></properties></rule></ruleset>
TheWPForms.PHP.ValidateDomain
sniff validates that you are using the correct text domain fori18n
functions such as__()
,_e()
,_n()
, etc.
By default, this sniff works for one domain in the project. We get a directory name based on thevendor
directory or the location of thephpcs.xml
/.phpcs.xml
file.
You can install our package to theplugins
directory and enable the multi-domain mode. in this case, the text domain will be the next folder name in the path. Structure:
../wp-content/plugins/ # → Root├── wpforms/ # → `wpforms` domain.└── wpforms-stripe/ # → `wpforms-stripe` domain.
In your config you should enable themulti_domains
property:
<?xml version="1.0"?><rulesetname="WPForms CS"><!-- ...--><configname="multi_domains"value="true"/><!-- ...--></ruleset>
If you have different domains for directories inside your project (for example, for free and paid versions) and want to redefine the text domain for some paths:
../wp-content/plugins/ # → Root├── wpforms/ # → `wpforms-lite` domain.│ ├── pro/ # → `wpforms` domain.│ └── src/ # → `wpforms-lite` domain.│ ├── Admin/ # → `wpforms-lite` domain.│ └── Pro/ # → `wpforms` domain.└── wpforms-stripe/ # → `wpforms-stripe` domain.
In this case, you should add to the config file the property withname
as a text domain andvalue
as a path. If a domain has several paths, then list them via commas.
<?xml version="1.0"?><rulesetname="WPForms CS"><!-- ...--><configname="multi_domains"value="true"/><ruleref="WPForms.PHP.ValidateDomain"><properties><propertyname="wpforms-lite"value="wpforms"/><propertyname="wpforms"value="wpforms/pro/,wpforms/src/Pro/"/></properties></rule><!-- ...--></ruleset>
About
PHP Coding Standards used by the WPForms team.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.