Skip to content

Instantly share code, notes, and snippets.

@ahmu83
Last active October 30, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmu83/ee6467b66ab1509c6ae9b77d151d0797 to your computer and use it in GitHub Desktop.
Save ahmu83/ee6467b66ab1509c6ae9b77d151d0797 to your computer and use it in GitHub Desktop.
LOCAL & PRODUCTION specific variables for a wordpress instance
<?php
/**
* @author Ahmad Karim <hello@ahmadkarim.com>
*
* DEV & PROD specific variables
* for WordPress when working with
* LOCAL & LIVE instances at the same time
*/
$localhosts = array('127.0.0.1', '::1');
$env = in_array($_SERVER['REMOTE_ADDR'], $localhosts) ? 'DEV' : 'PROD';
/**
* DB Credentials for DEV & PROD
*/
$DBs = array();
$DBs['DEV'] = array(
'NAME' => 'db_name',
'USER' => 'db_user',
'PASS' => 'db_pass',
'HOST' => 'localhost',
'PREFIX' => 'wp_',
'CHARSET' => 'utf8mb4',
'COLLATE' => '',
);
$DBs['PROD'] = array(
'NAME' => 'db_name',
'USER' => 'db_user',
'PASS' => 'db_pass',
'HOST' => 'localhost',
'PREFIX' => 'wp_',
'CHARSET' => 'utf8mb4',
'COLLATE' => '',
);
$DB = $DBs[$env];
/**
* URLs for DEV & PROD
*/
$URLs = array();
$URLs['DEV'] = array(
'HOME' => 'http://instance-url.com.test',
'SITEURL' => 'http://instance-url.com.test',
);
$URLs['PROD'] = array(
'HOME' => 'https://instance-url.com',
'SITEURL' => 'https://instance-url.com',
);
$URL = $URLs[$env];
/**
* WP_DEBUG value for DEV & PROD
*/
$DEBUG = ($env == 'DEV' ? true : false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment