From 6f060743283b47bfb2a661056ebc03731daf2434 Mon Sep 17 00:00:00 2001 From: Fabrizio Lungo Date: Wed, 28 Mar 2018 19:35:03 +0100 Subject: [PATCH] Add the ability to set WP_HOME This allows for a user to override the value in the wp_options table (useful for development instances) as well as reduce database calls on production instances. This also applies to wp_site_url and so I have added this use to the description for that parameter. I have added in some whitespace cleanup for the wp_site_url and wp_home tags in the wp-config.erb.php - it may be desirable to replicate this with all of the if/end statements in both template files to avoid unnecessary whitespace. --- README.markdown | 5 ++++- manifests/app.pp | 2 ++ manifests/init.pp | 7 ++++++- manifests/instance.pp | 7 ++++++- manifests/instance/app.pp | 2 ++ templates/wp-config.php.erb | 8 +++++--- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 7b6b799..633b46e 100644 --- a/README.markdown +++ b/README.markdown @@ -99,7 +99,10 @@ This will set up one or more installations of Wordpress 4.8.1 on Debian and Redh Specifies the port to use with the proxy host. Default: '' * `wp_site_url`
- If your WordPress server is behind a proxy, you might need to set the WP_SITEURL with this parameter. Default: 'undef' + If your WordPress server is behind a proxy, you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_SITEURL with this parameter. Default: 'undef' + +* `wp_home`
+ If you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_HOME with this parameter. Default: 'undef' * `wp_multisite`
Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` diff --git a/manifests/app.pp b/manifests/app.pp index 2a04201..da4e9c3 100644 --- a/manifests/app.pp +++ b/manifests/app.pp @@ -23,6 +23,7 @@ $wp_proxy_host, $wp_proxy_port, $wp_site_url, + $wp_home, $wp_multisite, $wp_site_domain, $wp_debug, @@ -53,6 +54,7 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_site_url => $wp_site_url, + wp_home => $wp_home, wp_multisite => $wp_multisite, wp_site_domain => $wp_site_domain, wp_debug => $wp_debug, diff --git a/manifests/init.pp b/manifests/init.pp index 34bcac9..b4de919 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -86,7 +86,10 @@ # Specifies the port to use with the proxy host. Default: '' # # [*wp_site_url*] -# If your WordPress server is behind a proxy, you might need to set the WP_SITEURL with this parameter. Default: `undef` +# If your WordPress server is behind a proxy, you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_SITEURL with this parameter. Default: `undef` +# +# [*wp_home*] +# If you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_HOME with this parameter. Default: `undef` # # [*wp_multisite*] # Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` @@ -134,6 +137,7 @@ $wp_proxy_host = '', $wp_proxy_port = '', $wp_site_url = undef, + $wp_home = undef, $wp_multisite = false, $wp_site_domain = '', $wp_debug = false, @@ -171,6 +175,7 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_site_url => $wp_site_url, + wp_home => $wp_home, wp_multisite => $wp_multisite, wp_site_domain => $wp_site_domain, wp_debug => $wp_debug, diff --git a/manifests/instance.pp b/manifests/instance.pp index 872c9d6..624bcf4 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -84,7 +84,10 @@ # Specifies the port to use with the proxy host. Default: '' # # [*wp_site_url*] -# If your WordPress server is behind a proxy, you might need to set the WP_SITEURL with this parameter. Default: `undef` +# If your WordPress server is behind a proxy, you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_SITEURL with this parameter. Default: `undef` +# +# [*wp_home*] +# If you wish to override the value in the wp_options table or reduce the number of database calls when loading, you might need to set the WP_HOME with this parameter. Default: `undef` # # [*wp_multisite*] # Specifies whether to enable the multisite feature. Requires `wp_site_domain` to also be passed. Default: `false` @@ -123,6 +126,7 @@ $wp_proxy_host = '', $wp_proxy_port = '', $wp_site_url = undef, + $wp_home = undef, $wp_multisite = false, $wp_site_domain = '', $wp_debug = false, @@ -158,6 +162,7 @@ wp_proxy_host => $wp_proxy_host, wp_proxy_port => $wp_proxy_port, wp_site_url => $wp_site_url, + wp_home => $wp_home, wp_multisite => $wp_multisite, wp_site_domain => $wp_site_domain, wp_debug => $wp_debug, diff --git a/manifests/instance/app.pp b/manifests/instance/app.pp index 1635199..6928c28 100644 --- a/manifests/instance/app.pp +++ b/manifests/instance/app.pp @@ -23,6 +23,7 @@ String $wp_proxy_host, String $wp_proxy_port, Optional[String] $wp_site_url, + Optional[String] $wp_home, Boolean $wp_multisite, String $wp_site_domain, Boolean $wp_debug, @@ -154,6 +155,7 @@ # - $wp_proxy_host # - $wp_proxy_port # - $wp_site_url + # - $wp_home # - $wp_multisite # - $wp_site_domain # - $wp_additional_config diff --git a/templates/wp-config.php.erb b/templates/wp-config.php.erb index f29611e..b849027 100644 --- a/templates/wp-config.php.erb +++ b/templates/wp-config.php.erb @@ -85,9 +85,12 @@ define('WP_PROXY_PORT', '<%= @wp_proxy_port %>'); <% end %> <% end %> -<% if @wp_site_url %> +<% if @wp_site_url -%> define('WP_SITEURL', '<%= @wp_site_url %>'); -<% end %> +<% end -%> +<% if @wp_home -%> +define('WP_HOME', '<%= @wp_home %>'); +<% end -%> <% if @wp_multisite %> /* Multisite */ @@ -111,4 +114,3 @@ if ( !defined('ABSPATH') ) /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php'); -