Skip to content

Commit f70e2a4

Browse files
Docs: Add a section for mu plugins (#43097)
* Docs: Add a section for mu plugins * Refer to custom code snippets section from JETPACK_DEV_DEBUG section
1 parent 886e119 commit f70e2a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/development-environment.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,29 @@ We strongly recommend that you install tools to review your code in your IDE. It
462462

463463
`add_filter( 'jetpack_offline_mode', '__return_true' );`
464464

465+
See the [Custom code snippets](#custom-code-snippets-mu-plugins) section for more information on how to add custom code snippets.
466+
465467
While in Offline Mode, some features will not be available at all as they require WordPress.com for all functionality—Related Posts and Jetpack Social, for example. Other features will have reduced functionality to give developers a good-faith representation of the feature. For example, Tiled Galleries requires the WordPress.com Photon CDN; however, in Offline Mode, Jetpack provides a fallback so developers can have a similar experience during development and testing. Find out more in [our support documentation](https://jetpack.com/support/jetpack-for-developers/).
466468

467469
* ### JETPACK__SANDBOX_DOMAIN
468470

469471
External contributors do not need this constant.
470472
If you’re working on changes to the WordPress.com/server side of Jetpack, you’ll need to instruct your Jetpack installation to talk to your development server. Refer to internal documentation for detailed instructions.
473+
474+
## Custom code snippets (mu-plugins)
475+
476+
You can add [mu-plugins](https://developer.wordpress.org/advanced-administration/plugins/mu-plugins/) inside `tools/docker/mu-plugins` like `0-snippets.php` to add custom code snippets to your test site. Those files are gitignored. This is useful for testing specific features or debugging issues.
477+
478+
For example, you can add the following code to the `0-snippets.php` file to use local Calypso URLs instead of the production ones for connecting a site.
479+
480+
```php
481+
add_filter(
482+
'jetpack_build_authorize_url',
483+
function ( $url ) {
484+
// Comment out this line when not using local Calypso development URL.
485+
$url = str_replace( 'https://wordpress.com', 'http://calypso.localhost:3000', $url );
486+
487+
return $url;
488+
}
489+
);
490+
```

0 commit comments

Comments
 (0)