Skip to content

Instantly share code, notes, and snippets.

@kfriend
Created March 18, 2013 20:50
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 kfriend/5190690 to your computer and use it in GitHub Desktop.
Save kfriend/5190690 to your computer and use it in GitHub Desktop.
Pre-Wordpress bootstrapping file which removes any development or staging domains from finalized output. Relies on an environment constant WP_ENVIRONMENT. Wordpress's index.php should be renamed to wordpress.php.
<?php
// Application bootstrap
// Start buffering output. We'll do some work on it later.
ob_start();
// Bootstrap Wordpress
// PHP 5.2 is still in use, so we cannot use __DIR__
require dirname(__FILE__).'/wordpress.php';
if (WP_ENVIRONMENT === 'production')
{
$find = array(
'example.dev',
'staging.example.com',
);
// Rewrite dev/preview URLs in final output
echo str_ireplace($find, 'example.com', ob_get_clean());
}
else
{
ob_end_flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment