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

Update WP template_root for multisite subsites when applicable #848

Closed
wants to merge 4 commits into from

Conversation

fullyint
Copy link
Contributor

Followup to #840 and its history. Fixes https://discourse.roots.io/t/multisite-subsite-using-twentyfifteen-theme/9871/5

This PR enables Trellis deploys to update template_root and stylesheet_root WP options also for multisite subsites, not just the primary site.

Multisite operators that wish to disable all this (e.g., in order to avoid the processing time) may add update_wp_theme_paths: false somewhere in group_vars, or disable it on the fly:

ansible-playbook deploy.yml -e env=production -e site=example.com -e update_wp_theme_paths=false

Re: xargs etc, see also https://danielbachhuber.com/tip/run-wp-cli-command-wordpress-multisite/

Re: bool filter, it is necessary for proper interpretation of cli -e update_wp_theme_paths=false (otherwise the var remains a string "false" interpreted as boolean true).

No longer assumes that template_root and stylesheet_root are within a .../web/wp/wp-content/themes subdirectory of the releases_directory (although I don't know where else they'd be).

fullyint added 2 commits July 14, 2017 12:21
Fixes problem occurring when site1 lacks template_root output,
resulting in missing newline in wp_template_root var, ultimately
causing stdout_lines to parse incorrectly when resetting template_root.

Also switches to submitting pre-filtered wp_template_root.stdout_lines
to the with_nested loop in effort to prevent Ansible output littered
with numerous skipped subsites for large multisite installations.
When a child theme is in Bedrock `web/app/themes` and its parent
theme is in different directory (e.g., `web/wp/wp-content/themes`),
stylesheet_root must be `/themes` while template_root should be
updated with the latest deploy releases_path. Prior to this PR,
stylesheet_root was always updated with template_root, causing
problems for some child themes.
@fullyint
Copy link
Contributor Author

The third commit Accommodate child themes: Update WP stylesheet_root separately addresses https://discourse.roots.io/t/template-root-not-updated-by-env/9724

When a child theme is in Bedrock web/app/themes and its parent theme is in different directory (e.g., web/wp/wp-content/themes), stylesheet_root must be /themes while template_root should be updated with the latest deploy releases_path. Prior to this commit, stylesheet_root was always updated with template_root, causing problems for some child themes.

Some WP themes may throw errors if loaded in this context,
e.g., some PHP classes may not be available with `--skip-plugins`.
It is not necessary to load themes when updating WP options for
template_root and stylesheet root, so it is safer to `--skip-themes`.
@fullyint
Copy link
Contributor Author

The fourth commit Deploys: --skip-themes when updating WP template_root addresses https://discourse.roots.io/t/deploy-failing-at-task-deploy-get-wp-theme-template-root/10017

Some WP themes may throw errors if loaded in this context, e.g., some PHP classes may not be available with --skip-plugins. It is not necessary to load themes when updating WP options for template_root and stylesheet_root, so it is safer to --skip-themes.

Trellis already uses --skip-themes in conjunction with --skip-plugins in the WordPress Installed? task.

@fullyint
Copy link
Contributor Author

Closing. Will split into small chunks for easier testing and review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant