Open topdown opened 8 years ago
I made some minor updates to the pull request referenced in #24 so that it works as I originally intended.
It should work for normal WP sites and wp-starter sites, but is untested for bedrock sites.
For a real refactoring, we should first discuss the different data (mainly folders) that are needed and how to consistently name, retrieve and use them. I suggest using the following variables and retrieving them in one go per site:
$host->domain
: The URL to the site's frontpage (localsite.dev
)$host->path
: The server path to the site's root (/srv/www/localsite.com/htdocs
)$host->wp
: The server path to the site's WordPress install ( /srv/www/ localsite.com/htdocs/wp
)The rest of the code should not care whether it is a wp-starter site or not, it should just know whether it needs the domain, the root, or the WP install, and blindly use the corresponding variable. This eliminates a lot of if/else
redundancy.
Furthermore, I suggest using an extensible class hierarchy to deal with a host:
HostInterface
AbstractHost implements HostInterface
StandardWP extends AbstractHost
WPStarter extends AbstractHost
Bedrock extends AbstractHost
All the code dealing with hosts should do this via public methods of the HostInterface
contract.
This way, a new type of host can be added without changing existing code.
So, the above variables would be fetched like this:
<?php
public function print_host_domain( HostInterface $host ) {
echo $host->get_name();
}
We need to refactor a lot of code, its become a mess with all of the features I cranked out last time I worked on this. Related to these issues #15 #20 #22
See issues related in this PR https://github.com/topdown/VVV-Dashboard/pull/24
If anyone is using Starter packages please list them here with a link to the repo so they can be tested. WPStarter https://github.com/wecodemore/wpstarter Bedrock https://github.com/roots/bedrock
I have a repo setup for example installers with paths that currently cause issues and need to be tested against. https://github.com/topdown/WP-Installers
Work on this ticket should be done against the
refactor-hosts
branch.