Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wp_toggle_dev_plugins example #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions wp_toggle_dev_plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Toggle Developer Plugins on WordPress Sites #

This example will show how you can automatically activate and deactivate plugins based on environment on deploy. This will ease development and potentially improve performance on Live.

## Instructions ##

Setting up this example is easy:

1. Add the wp_toggle_dev_plugins.php to the `private/scripts` directory of your code repository.
2. Add a Quicksilver operation to your `pantheon.yml` to fire the script a deploy.
3. Test a deploy out!

Optionally, you may want to use the `terminus workflow:watch` command to get immediate debugging feedback.

### Example `pantheon.yml` ###

Here's an example of what your `pantheon.yml` would look like if this were the only Quicksilver operation you wanted to use:

```yaml
api_version: 1

workflows:
deploy:
after:
# Toggle developer plugins
- type: webphp
description: Toggle developer plugins
script: private/scripts/wp_toggle_dev_plugins.php
```
20 changes: 20 additions & 0 deletions wp_toggle_dev_plugins/wp_toggle_dev_plugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
// hello is our example plugin, swap out with the slug of your plugin of choice
echo "Toggle developer plugins: checking environment... \n";
if ( ! empty( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
switch( $_ENV['PANTHEON_ENVIRONMENT'] ) {
case 'live':
echo "Toggle developer plugins: Live, deactivating plugins... \n";
passthru('wp plugin deactivate hello ');
break;
case 'test':
echo "Toggle developer plugins: Test, activating plugins... \n";
passthru('wp plugin activate hello ');
break;
case 'dev':
echo "Toggle developer plugins: Dev, activating plugins... \n";
passthru('wp plugin activate hello ');
break;
}
}
?>