Skip to content

Instantly share code, notes, and snippets.

@zaus
Created December 11, 2015 21:06
Show Gist options
  • Save zaus/9b52909f80bb01986001 to your computer and use it in GitHub Desktop.
Save zaus/9b52909f80bb01986001 to your computer and use it in GitHub Desktop.

Revisions

  1. zaus created this gist Dec 11, 2015.
    19 changes: 19 additions & 0 deletions enviro-switch.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    switch($_SERVER['HTTP_HOST']) {
    case 'wp.sandbox:81':
    define('DB_NAME', 'YOURDB');/** The name of the database for WordPress */
    define('DB_USER', 'YOURUSER');/** MySQL database username */
    define('DB_PASSWORD', 'YOURPASS');/** MySQL database password */
    define('DB_HOST', 'localhost');/** MySQL hostname */ // may need to use actual computer ip in some cases
    break;
    default:
    define('DB_NAME', 'YOURDB');/** The name of the database for WordPress */
    define('DB_USER', 'YOURUSER');/** MySQL database username */
    define('DB_PASSWORD', 'YOURPASS');/** MySQL database password */
    define('DB_HOST', 'localhost');/** MySQL hostname */ // may need to use actual computer ip in some cases
    break;
    }

    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8mb4');
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    21 changes: 21 additions & 0 deletions wp-config-debug.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);

    // http://fuelyourcoding.com/simple-debugging-with-wordpress/
    if(!function_exists('_log')):
    function _log( $message ) {
    $message = func_get_args();
    if( WP_DEBUG !== true ) return;

    $e = new Exception();
    $backtrace = str_replace(getcwd(), '', $e->getTraceAsString());
    // do we print the whole backtrace? or just the first line
    if($message[0] !== 'backtrace') $backtrace = explode("\n"/*PHP_EOL*/, $backtrace)[0];
    error_log(sprintf('DEBUG AT: %s%s%s'
    , $backtrace
    , PHP_EOL
    , print_r( count($message) == 1 ? $message[0] : $message, true )
    ));
    }
    endif;