Skip to content

Commit 4a9b125

Browse files
Merge pull request #1098 from Codeinwp/development
Prepare Visualizer Store Preview
2 parents c295dee + 1dc3e08 commit 4a9b125

File tree

2 files changed

+39
-18
lines changed

2 files changed

+39
-18
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ For specific signs:
121121
2. Except the number formatting will be `$#,###`.
122122

123123
# 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)
127128

128129
# Setup Guide
129130

@@ -136,7 +137,8 @@ WordPress, PHP, MySQL and Git - but you're free to use your preferred software.
136137

137138
### LAMP/LEMP stack
138139

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+
140142
- Valet (recommended)
141143
- Local by Flywheel
142144
- Docker
@@ -173,6 +175,7 @@ In the cloned repository's directory, at the command line, run `composer install
173175
This will install the development dependencies. If you want to install just the production dependencies, run `composer install --no-dev`.
174176

175177
The development dependencies include:
178+
176179
- PHPStan
177180
- PHPUnit
178181
- PHP_CodeSniffer
@@ -192,14 +195,13 @@ To fix automatically fixable issues, run `composer format`.
192195
To run PHPUnit, run `phpunit` or `./vendor/bin/phpunit` if it is not configured globally.
193196

194197
### E2E Tests
198+
195199
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).
196200

197201
### Next Steps
198202

199203
With your development environment setup, you'll probably want to start development, which is covered bellow in the **Development Guide**.
200204

201-
202-
203205
# Development Guide
204206

205207
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
211213
If you haven't yet set up your local development environment with a WordPress Plugin repository installed, refer to the [Setup Guide](#setup-guide).
212214

213215
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+
214217
- 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
215218

216219
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
226229

227230
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()`.
228231

229-
When writing to the database, prepare database queries using ``$wpdb->prepare()``
232+
When writing to the database, prepare database queries using `$wpdb->prepare()`
230233

231234
Never trust user input. Sanitize it.
232235

@@ -236,7 +239,7 @@ Coding standards will catch any sanitization, escaping or database queries that
236239

237240
## Composer Packages
238241

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`.
240243

241244
### "require"
242245

@@ -253,6 +256,7 @@ Packages listed in the "require-dev" directive are packages that the Plugin **do
253256
These packages are **not** included when the Plugin is deployed to wordpress.org
254257

255258
Typically, packages listed in this section would be internal development tools for testing, such as:
259+
256260
- Coding Standards
257261
- PHPStan
258262
- PHPUnit
@@ -266,14 +270,13 @@ If it's a particularly large commit, be sure to include more information in the
266270

267271
## Next Steps
268272

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
270274
on how to write a test.
271275

272-
273-
274276
# Testing Guide
275277

276278
This document describes how to:
279+
277280
- create and run tests for your development work,
278281
- ensure code meets PHP and WordPress Coding Standards, for best practices and security,
279282
- 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
302305
## Types of Test
303306

304307
There are different types of tests that can be written:
308+
305309
- Acceptance Tests: Test as a non-technical user in the web browser.
306310
- Functional Tests: Test the framework (WordPress).
307311
- 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:
310314

311315
There is no definitive / hard guide, as a test can typically overlap into different types (such as Acceptance and Functional).
312316

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.
314318

315319
### Writing an Acceptance Test
316320

@@ -330,7 +334,7 @@ You can check End-to-End [README](./e2e-tests/README.md) for more details.
330334
## Writing a WordPress Unit Test
331335

332336
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
334338
the correct data.
335339

336340
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
346350
* @var \WpunitTester
347351
*/
348352
protected $tester;
349-
353+
350354
public function setUp(): void
351355
{
352356
// Before...
@@ -363,7 +367,7 @@ class APITest extends \PHPUnit\Framework\TestCase
363367
public function test_it_works()
364368
{
365369
$post = static::factory()->post->create_and_get();
366-
370+
367371
$this->assertInstanceOf(\WP_Post::class, $post);
368372
}
369373
}
@@ -385,7 +389,7 @@ In the Plugin's or Theme's directory, run the following command to run PHP_CodeS
385389
as defined in the `phpcs.tests.xml` configuration:
386390

387391
```bash
388-
composer run lint
392+
composer run lint
389393
```
390394

391395
`--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.
395399
`-s` specifies the precise rule that failed
396400

397401
Any errors should be corrected by either:
402+
398403
- making applicable code changes
399404
- running `composer run format` to automatically fix coding standards
400405

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+
402408
- ignore a rule in the affected code, by adding `phpcs:ignore {rule}`, where {rule} is the given rule that failed in the above output.
403409
- edit the [phpcs.tests.xml](phpcs.tests.xml) file.
404410

@@ -409,6 +415,21 @@ Once your test(s) are written and successfully run locally, submit your branch v
409415
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
410416
double-check all tests pass.
411417

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.
413419

414420
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/).
427+
428+
Examples:
429+
430+
- https://github.com/dss-web/jobbnorge-block/blob/main/.wordpress-org/blueprints/blueprint.json
431+
- https://github.com/WordPress/wordpress-playground/blob/c6da5d622e7e49bd151bab7b72ac17501a21fea5/packages/docs/site/docs/03-build-an-app/01-index.md
432+
- https://github.com/TablePress/TablePress/blob/62aab50e7a9c486caaeff26dff4dc01e059ecb91/.wordpress-org/blueprints/blueprint.json
433+
- https://github.com/johnbillion/user-switching/blob/d26e982fc1389fff24e6d6572e238066e2b056d2/.wordpress-org/blueprints/blueprint.json
434+
- https://github.com/10up/ads-txt/blob/ef95e10f5a9973aaf4cad773e8e78aafd03af059/.wordpress-org/blueprints/blueprint.json
435+
- https://github.com/janw-me/default-featured-image/blob/de4d226216105f3d8c573dfbf28bbba89330286e/.wordpress-org/blueprints/blueprint.json

0 commit comments

Comments
 (0)