When starting with a fresh Network install, the first step is a single site install that has one additional line in the wp-config.php
file:
define( 'WP_ALLOW_MULTISITE', true );
After that we have to go to Tools > Network Setup
, enter some details like network name and super admin email and finally hit the button to run the setup.
The next step the pops up is actually two steps:
Add additional constants to your
wp-config.php
filedefine( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); define( 'DOMAIN_CURRENT_SITE', 'example.com' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', true ); define( 'BLOG_ID_CURRENT_SITE', true );
- Add some rules to your
.htaccess
file.
As I don't do single site installs (no reason for that anymore), I'd like to add those constants dynamically to my wp-config.php
file:
define( 'WP_ALLOW_MULTISITE', true );
if ( SOME_CHECK_IF_STEP-1_WAS_PASSED )
{
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'example.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', true );
define( 'BLOG_ID_CURRENT_SITE', true );
}
So I don't have to go to the wp-config.php
each time and edit it again.
The 1st thing that came into my mind was to check the DB for the {$wpdb->prefix}sitemeta
table, but I don't want to do an additional query on each site load. The 2nd thing I thought of was to check if the blogs.dir
already exists, but that's not the case.
Question: How can I indicate that I already passed the first step of the network setup in way that doesn't has a massive overhead or decreases performance.
wp-config
generator.