Thank you for your interest in contributing to the WPTechnix WordPress Coding Standards! This document provides guidelines and instructions for contributing to the project.
By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors. We expect everyone to follow our Code of Conduct.
If you find a bug, have a suggestion for a new rule, or want to discuss an existing one:
- Check if the issue already exists in the GitHub Issues.
- If not, create a new issue with a clear title and a detailed description.
- Include relevant details such as:
- PHP version (must be 8.0+).
- PHP_CodeSniffer and WordPress Coding Standards versions.
- Example code that demonstrates the issue.
- The expected behavior vs. the actual behavior.
- Fork the repository.
- Create a new branch from
mainfor your feature or fix:git checkout -b feat/your-feature-name
- Make your changes and commit them using the Conventional Commits format:
git commit -m "feat: add rule for WP_Query best practices" - Push your branch to your forked repository:
git push origin feat/your-feature-name
- Open a Pull Request against the
mainbranch of the original repository.
This project uses Conventional Commits for automated versioning and changelog generation. All commit messages must adhere to this specification.
<type>(<scope>): <subject>
<body>
<footer>
feat: A new feature (e.g., adding a new sniff) - triggers a minor version bump.fix: A bug fix (e.g., correcting a rule's behavior) - triggers a patch version bump.docs: Documentation changes only.style: Code style changes (formatting, etc.).refactor: Code refactoring without changing external behavior.perf: A code change that improves performance.test: Adding or updating tests.build: Changes to the build system or external dependencies.ci: Changes to CI configuration files and scripts.chore: Other changes that don't modify source or test files.revert: Reverting a previous commit.
To indicate a breaking change, add BREAKING CHANGE: in the commit footer or add a ! after the type. This will trigger a major version bump.
feat!: remove deprecated WordPress rule
BREAKING CHANGE: The `WordPress.WP.DeprecatedFunctions` rule has been removed in favor of a more comprehensive solution.
- PHP 8.0 or higher
- Composer 2.x
- Node.js 18.0 or higher
- npm 9.0 or higher
-
Clone the repository:
git clone https://github.com/wptechnix/wordpress-coding-standards.git cd wordpress-coding-standards -
Install Composer dependencies:
composer install
-
Install Node.js dependencies (for commit message validation):
npm install
This automatically sets up Husky git hooks to validate your commit messages locally before you commit.
Before submitting a pull request, it is crucial to test your changes locally to ensure they work as expected.
- Create a temporary PHP file on your local machine. This file is for your testing purposes and should not be included in your pull request.
- In this file, add various code samples that your changes should affect. Include examples of code that should trigger an error and code that should pass inspection.
- From the root of the project, run PHP_CodeSniffer against your local test file:
./vendor/bin/phpcs --standard=WPTechnixWordPress /path/to/your/local/test-file.php
- Verify that the output from PHP_CodeSniffer matches your expectations.
When adding, removing, or modifying rules in WPTechnixWordPress/ruleset.xml:
- Provide a clear reason for the change in your commit message and pull request.
- Ensure the rule does not conflict with existing rules in the base
WPTechnixstandard or other WordPress rules. - Test the changes with real-world WordPress code examples.
- Update the
README.mdor other documentation if the changes are significant.
Releases are fully automated using release-please.
- When pull requests with conventional commit messages are merged into the
mainbranch, therelease-pleaseaction creates or updates a "Release PR." - This special PR contains an updated
CHANGELOG.mdand the next version number based on the types of commits merged (fix,feat,feat!, etc.). - When the Release PR is merged, the following happens automatically:
- A new Git tag (e.g.,
v1.2.0) is created. - A new GitHub Release is published with the generated changelog.
- Packagist detects the new tag and publishes the new version to the package repository.
- A new Git tag (e.g.,
Important: Do not manually edit the CHANGELOG.md or the version number. The automated process handles this entirely.
By contributing to this project, you agree that your contributions will be licensed under its MIT License.