trendwerk/domains

Domains for WordPress Multisite.

Installs: 5 953

Dependents: 0

Suggesters: 0

Security: 0

Stars: 24

Watchers: 5

Forks: 1

Open Issues: 0

Type:wordpress-muplugin

0.2.0 2016-12-23 13:52 UTC

This package is auto-updated.

Last update: 2024-04-26 18:59:01 UTC


README

Domains for WordPress Multisite.

Requires WordPress 4.5+. Specifically meant for using domains on subdirectory Multisite installs.

Note: This plugin does not replace all existing URLs in the database. Therefore, it is recommended to install this immediately after creating a multisite install.

Installation

If you're using Composer to manage WordPress, add this plugin to your project's dependencies. Run:

composer require trendwerk/domains

Setup

The basic setup of this plugin consists of two steps:

  1. Define the correct constants in your WordPress configuration file (default: wp-config.php)
  2. Configure the .domains file, which is the main configuration file for this plugin

Constants

define('SUNRISE', true);

This activates a WordPress drop-in plugin called sunrise.php. Allows this plugin to perform actions right before Multisite is loaded.

define('CONTENT_DIR', '/app');

This is only necessary if your content folder is not located in the default /wp-content folder. The example above uses /app.

define('DOMAIN_CURRENT_SITE', 'www.example.com');

Probably not necessary to say, but this should be defined when using Multisite. This plugin relies on it being defined as well.

Omit these constants

Never define the following constants when using Multisite and this plugin:

  • WP_CONTENT_URL - should be defined by this plugin
  • WP_HOME - not used by Multisite
  • WP_SITEURL - not used by Multisite

Configuration

The .domains file is the main configuration file for this plugin and contains all domains. It is set up in the format blogId:domain. Domain aliases can be created by separating domains by a comma. For example:

2=www.example.com,example.com
3=www.example.org

The domains file should be located in the root of your project. This file should probably be excluded from version control, since enviroments are usually run on different domains. When using Capistrano for deployment, it should be defined as a linked file.

Note: This plugin searches for the .domains file in the folder where WordPress is located and a maximum of two folders up.