Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mgussekloo/c682716f9251f6cf44433362ba863c11 to your computer and use it in GitHub Desktop.
Save mgussekloo/c682716f9251f6cf44433362ba863c11 to your computer and use it in GitHub Desktop.
Plugin that lets you share Wordpress sites through Expose (expose.dev)
<?php
// phpcs:ignoreFile
define( 'EXPOSED_DOMAIN', 'xxx.sharedwithexpose.com' );
define( 'REAL_DOMAIN', 'mydomain.test' );
// Load only if we are running under Expose.
if ( empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) || strpos($_SERVER['HTTP_X_ORIGINAL_HOST'], EXPOSED_DOMAIN) === false) {
return;
}
ob_start(function($buffer) {
return str_replace(REAL_DOMAIN, EXPOSED_DOMAIN, $buffer);
});
add_action('shutdown', function() {
ob_end_flush();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment