Pilothouse-App / Pilothouse

A command line app for managing a LEMP local development environment based on Docker.
http://pilothouse-app.org
GNU General Public License v2.0
98 stars 17 forks source link

Add site and url WordPress constants #116

Open jacobarriola opened 5 years ago

jacobarriola commented 5 years ago

It would be easier to have these constants set, as most of the sites that spin up are existing, which have set urls in the options table. I don't know whether PH has a variable for the local url, but {{site_name}} is a start. The TLD (.dev) is probably problematic as well as the set protocol I have (http). Happy to get more information or open up a dialogue.

philipnewcomer commented 5 years ago

@jacobarriola I generally do a DB search/replace of the live URL to the local URL whenever I import a production database, but I can see how this change would be helpful in not requiring that step.

Currently, in config/wp-config.php.inc there is only one template variable available, site_name. However, you can add more template variables in the createSite() function located in utils/sites.js. This line generates the content to add to wp-config.php:

wpConfigAdditionsContent = helpers.populateTemplate(wpConfigAdditionsContent, {site_name: environment.currentSiteName});

The object containing site_name contains the variables that will be available in the template, and I'd recommend creating a new variable site_url. I believe the full domain (including TLD) that the user specifies when creating the site can be found in siteConfig.domain. So you'd just need to add a protocol to that in order to have the full site URL that you can use in the wp-config constant.

So that just leaves us to decide whether to default to HTTP or HTTPS. I think the choice is pretty clear that we should default to HTTPS.