Skip to content

Commit

Permalink
Merge branch 'develop' into as-8871-ece-on-supported-product-types
Browse files Browse the repository at this point in the history
  • Loading branch information
asumaran committed Jul 5, 2024
2 parents bcf8bfa + c93f5e8 commit 231e02a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ contributors.md
# Volumes mounted by Docker containers
docker/data
docker/wordpress
docker/mu-plugins
docker/logs

# Local machine docker override
Expand Down
5 changes: 5 additions & 0 deletions changelog/dev-add-docker-support-for-local-mu-plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Add support for mu-plugins.


1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- default.env
volumes:
- ./docker/wordpress:/var/www/html/
- ./docker/mu-plugins:/var/www/html/wp-content/mu-plugins
- ./docker/logs/apache2/:/var/log/apache2
- .:/var/www/html/wp-content/plugins/woocommerce-payments
- ./docker/wc-payments-php.ini:/usr/local/etc/php/conf.d/wc-payments-php.ini
Expand Down
14 changes: 14 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ services:
```
I used port `9003` as an example.
To apply the change, restart your containers using `npm run down && npm run up`

### Adding local helper scripts/hacks

You can add local PHP scripts in the `docker/mu-plugins` directory since it's mounted as the `wp-content/mu-plugins` WordPress directory in your Docker container. These PHP scripts will be loaded automatically because they are treated as [WordPress must-use plugins](https://developer.wordpress.org/advanced-administration/plugins/mu-plugins/).

**Note:** Please make sure that you try to think of these scripts as _temporary solutions/helpers_ and not as permanent code to be run constantly (unless you are sure that is what you want).

One _recommended way_ of working with your collection of helper scripts is to take advantage of the fact that _WordPress will not automatically load PHP files_ in subdirectories of `wp-content/mu-plugins` (as it does with regular plugins in `wp-content/plugins`).

1. Create a new directory in `docker/mu-plugins` for your scripts, e.g. `docker/mu-plugins/local-helpers`. WordPress will not automatically load PHP files in subdirectories of `mu-plugins`, so you need to include them manually.
2. Create a new PHP file in `docker/mu-plugins`,e.g. `docker/mu-plugins/0-local-helpers.php`.
3. Add lines like `require_once __DIR__ . '/local-helpers/your-script.php';` to `docker/mu-plugins/0-local-helpers.php` to load your scripts.
4. Comment/uncomment the `require_once` lines to load the scripts you need for your particular itch.
5. Make sure you comment out any lines once you are finished with that itch to avoid unexpected/non-standard behavior on your local environment going forward - leftover helpers are not helpful!
Empty file added docker/mu-plugins/.gitkeep
Empty file.

0 comments on commit 231e02a

Please sign in to comment.