Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHP Coding Standards used by the WPForms team.

License

NotificationsYou must be signed in to change notification settings

awesomemotive/wpforms-phpcs

Repository files navigation

Maintainers: The WPForms team

License: GPLv2 any later version.
License URI:http://www.gnu.org/licenses/gpl-2.0.html

Description

WPForms coding standards are based on theWordPress Coding Standards and thePHPCompatibility Coding Standards and help create strict and high-quality code.

Installation

composer config repositories.repo-name vcs https://github.com/awesomemotive/wpforms-phpcs.gitcomposer require awesomemotive/wpforms-phpcs --dev

Configuration

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>

Sniffs detail

Validate Text Domain Sniff

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

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp