You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+39-18Lines changed: 39 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,9 +121,10 @@ For specific signs:
121
121
2. Except the number formatting will be `$#,###`.
122
122
123
123
# CONTRIBUTING GUIDELINES
124
-
+[Setup Guide](#setup-guide)
125
-
+[Development Guide](#development-guide)
126
-
+[Testing Guide](#testing-guide)
124
+
125
+
-[Setup Guide](#setup-guide)
126
+
-[Development Guide](#development-guide)
127
+
-[Testing Guide](#testing-guide)
127
128
128
129
# Setup Guide
129
130
@@ -136,7 +137,8 @@ WordPress, PHP, MySQL and Git - but you're free to use your preferred software.
136
137
137
138
### LAMP/LEMP stack
138
139
139
-
Any Apache/nginx, PHP 7.x+ and MySQL 5.8+ stack running WordPress. For example, but not limited to:
140
+
Any Apache/nginx, PHP 7.x+ and MySQL 5.8+ stack running WordPress. For example, but not limited to:
141
+
140
142
- Valet (recommended)
141
143
- Local by Flywheel
142
144
- Docker
@@ -173,6 +175,7 @@ In the cloned repository's directory, at the command line, run `composer install
173
175
This will install the development dependencies. If you want to install just the production dependencies, run `composer install --no-dev`.
174
176
175
177
The development dependencies include:
178
+
176
179
- PHPStan
177
180
- PHPUnit
178
181
- PHP_CodeSniffer
@@ -192,14 +195,13 @@ To fix automatically fixable issues, run `composer format`.
192
195
To run PHPUnit, run `phpunit` or `./vendor/bin/phpunit` if it is not configured globally.
193
196
194
197
### E2E Tests
198
+
195
199
If the folder `e2e-tests` is present, you can run the E2E tests by following the instructions in the [E2E testing](./e2e-tests/README.md).
196
200
197
201
### Next Steps
198
202
199
203
With your development environment setup, you'll probably want to start development, which is covered bellow in the **Development Guide**.
200
204
201
-
202
-
203
205
# Development Guide
204
206
205
207
This document describes the high level workflow used when working on a WordPress Plugin or Theme.
@@ -211,6 +213,7 @@ You're free to use your preferred IDE and Git client. We recommend PHPStorm or V
211
213
If you haven't yet set up your local development environment with a WordPress Plugin repository installed, refer to the [Setup Guide](#setup-guide).
212
214
213
215
his is for a new feature that does not have a GitHub Issue number, enter a short descriptive name for the branch, relative to what you're working on
216
+
214
217
- If this is for a feature/bug that has a GitHub Issue number, enter feat/issue_name or fix/issue_name, where issue_name is a descriptive name for the issue
215
218
216
219
Once done, make sure you've switched to your new branch, and begin making the necessary code additions/changes/deletions.
@@ -226,7 +229,7 @@ When [outputting data](https://developer.wordpress.org/plugins/security/securing
226
229
227
230
When reading [user input](https://developer.wordpress.org/plugins/security/securing-input/), sanitize it using WordPress' sanitization functions such as `sanitize_text_field()`, `sanitize_textarea_field()`.
228
231
229
-
When writing to the database, prepare database queries using ``$wpdb->prepare()``
232
+
When writing to the database, prepare database queries using `$wpdb->prepare()`
230
233
231
234
Never trust user input. Sanitize it.
232
235
@@ -236,7 +239,7 @@ Coding standards will catch any sanitization, escaping or database queries that
236
239
237
240
## Composer Packages
238
241
239
-
We use Composer for package management. A package can be added to one of two sections of the `composer.json` file: `require` or `require-dev`.
242
+
We use Composer for package management. A package can be added to one of two sections of the `composer.json` file: `require` or `require-dev`.
240
243
241
244
### "require"
242
245
@@ -253,6 +256,7 @@ Packages listed in the "require-dev" directive are packages that the Plugin **do
253
256
These packages are **not** included when the Plugin is deployed to wordpress.org
254
257
255
258
Typically, packages listed in this section would be internal development tools for testing, such as:
259
+
256
260
- Coding Standards
257
261
- PHPStan
258
262
- PHPUnit
@@ -266,14 +270,13 @@ If it's a particularly large commit, be sure to include more information in the
266
270
267
271
## Next Steps
268
272
269
-
Once you've finished your feature or issue, you must write/amend tests for it. Refer to the [Testing Guide](#testing-guide) for a detailed walkthrough
273
+
Once you've finished your feature or issue, you must write/amend tests for it. Refer to the [Testing Guide](#testing-guide) for a detailed walkthrough
270
274
on how to write a test.
271
275
272
-
273
-
274
276
# Testing Guide
275
277
276
278
This document describes how to:
279
+
277
280
- create and run tests for your development work,
278
281
- ensure code meets PHP and WordPress Coding Standards, for best practices and security,
279
282
- ensure code passes static analysis, to catch potential errors that tests might miss
@@ -302,6 +305,7 @@ Tests are written in TS using [Playwright](https://playwright.dev/) and PHP usin
302
305
## Types of Test
303
306
304
307
There are different types of tests that can be written:
308
+
305
309
- Acceptance Tests: Test as a non-technical user in the web browser.
306
310
- Functional Tests: Test the framework (WordPress).
307
311
- Integration Tests: Test code modules in the context of a WordPress website.
@@ -310,7 +314,7 @@ There are different types of tests that can be written:
310
314
311
315
There is no definitive / hard guide, as a test can typically overlap into different types (such as Acceptance and Functional).
312
316
313
-
The most important thing is that you have a test for *something*. If in doubt, an Acceptance Test will suffice.
317
+
The most important thing is that you have a test for _something_. If in doubt, an Acceptance Test will suffice.
314
318
315
319
### Writing an Acceptance Test
316
320
@@ -330,7 +334,7 @@ You can check End-to-End [README](./e2e-tests/README.md) for more details.
330
334
## Writing a WordPress Unit Test
331
335
332
336
WordPress Unit tests provide testing of Plugin/Theme specific functions and/or classes, typically to assert that they perform as expected
333
-
by a developer. This is primarily useful for testing our API class, and confirming that any Plugin registered filters return
337
+
by a developer. This is primarily useful for testing our API class, and confirming that any Plugin registered filters return
334
338
the correct data.
335
339
336
340
To create a new WordPress Unit Test, create a new file under `tests/php/unit` with the name of the class you are testing, and the suffix `Test`.
@@ -346,7 +350,7 @@ class APITest extends \PHPUnit\Framework\TestCase
346
350
* @var \WpunitTester
347
351
*/
348
352
protected $tester;
349
-
353
+
350
354
public function setUp(): void
351
355
{
352
356
// Before...
@@ -363,7 +367,7 @@ class APITest extends \PHPUnit\Framework\TestCase
@@ -385,7 +389,7 @@ In the Plugin's or Theme's directory, run the following command to run PHP_CodeS
385
389
as defined in the `phpcs.tests.xml` configuration:
386
390
387
391
```bash
388
-
composer run lint
392
+
composer run lint
389
393
```
390
394
391
395
`--standard=phpcs.tests.xml` tells PHP CodeSniffer to use the Coding Standards rules / configuration defined in `phpcs.tests.xml`.
@@ -395,10 +399,12 @@ in test coding style.
395
399
`-s` specifies the precise rule that failed
396
400
397
401
Any errors should be corrected by either:
402
+
398
403
- making applicable code changes
399
404
- running `composer run format` to automatically fix coding standards
400
405
401
-
Need to change the PHP or WordPress coding standard rules applied? Either:
406
+
Need to change the PHP or WordPress coding standard rules applied? Either:
407
+
402
408
- ignore a rule in the affected code, by adding `phpcs:ignore {rule}`, where {rule} is the given rule that failed in the above output.
403
409
- edit the [phpcs.tests.xml](phpcs.tests.xml) file.
404
410
@@ -409,6 +415,21 @@ Once your test(s) are written and successfully run locally, submit your branch v
409
415
It's best to create a Pull Request in draft mode, as this will trigger all tests to run as a GitHub Action, allowing you to
410
416
double-check all tests pass.
411
417
412
-
If the PR tests fail, you can make code changes as necessary, pushing to the same branch. This will trigger the tests to run again.
418
+
If the PR tests fail, you can make code changes as necessary, pushing to the same branch. This will trigger the tests to run again.
413
419
414
420
If the PR tests pass, you can publish the PR, assigning some reviewers.
421
+
422
+
## Miscellaneous
423
+
424
+
### WordPress Store Plugin Preview
425
+
426
+
The plugin preview for the WordPress store is available via the `.wordpress-org/blueprints/blueprint.json` file. Read more about this feature in the [announcement](https://make.wordpress.org/meta/2023/12/08/plugin-previews-are-now-available-for-opt-in/).
0 commit comments