Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Last active October 8, 2021 20:26
Show Gist options
  • Save LinzardMac/feb55e6b10958774ecd5823d7608a6dd to your computer and use it in GitHub Desktop.
Save LinzardMac/feb55e6b10958774ecd5823d7608a6dd to your computer and use it in GitHub Desktop.
Stupid simple conditional config for local and production w/ constants.
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
define( 'WP_LOCAL_DEV', true ); // use this throughout if you have special "local-only" code.
define( 'SUNRISE', 'on' );
// ** MySQL settings - You can get this info from your web host ** //
if ( WP_LOCAL_DEV == true ) {
include( dirname( __FILE__ ) . '/local-config.php' );
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
} else {
define( 'WP_DEBUG', false );
// ** MySQL settings - You can get this info from your web host ** //
define( 'DB_NAME', '{$my_database}' );
define( 'DB_USER', '{$db_user}' );
define( 'DB_HOST', 'localhost' );
define( 'DB_PASSWORD', '{$password}' );
// ** Domain and Location settings **//
define('DOMAIN_CURRENT_SITE', 'mydomain.com');
define('WP_HOME','http://mydomain.com');
define('WP_SITEURL','http://mydomain.com');
}
/** Global database settings **/
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
/** Global WP Configuration settings **/
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
/** Global location settings **/
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/** WordPress Database Table prefix. **/
$table_prefix = 'wp_';
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
<?php
/**
* The base configuration for WordPress
*
* Configuration settings specific to a local installation of this WordPress package.*/
// ** MySQL settings - You can get this info from your web host ** //
define( 'DB_NAME', '{$my_local_database}' );
define( 'DB_USER', '{$db_user}' );
define( 'DB_PASSWORD', '{$password}' );
define( 'DB_HOST', '127.0.0.1' );
// ** Domain and Location settings **//
define('DOMAIN_CURRENT_SITE', 'mydomain.locdev'); // these should reflect your virtualhost settings
define('WP_HOME','http://mydomain.locdev');
define('WP_SITEURL','http://mydomain.locdev');
@bewebbed
Copy link

bewebbed commented Oct 4, 2021

Nice work around, i like it 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment