Skip to content

Instantly share code, notes, and snippets.

@herewithme
Last active December 1, 2015 13:19
Show Gist options
  • Save herewithme/62dc06dc1c134426e041 to your computer and use it in GitHub Desktop.
Save herewithme/62dc06dc1c134426e041 to your computer and use it in GitHub Desktop.
Force replace original domain by mapped domain for WPMU Domain Mapping
<?php
/*
Plugin Name: BEA Domain Mapping
Description: Always force replace original domain by mapping domain
Plugin URI: http://www.beapi.fr
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
ob_start( 'ob_domain_mapping_body' );
function ob_domain_mapping_body( $html ) {
global $wpdb;
if ( !function_exists('domain_mapping_siteurl') ) {
return false;
}
$orig_url = get_original_url( 'siteurl' );
$url = domain_mapping_siteurl( 'NA' );
if ( 'NA' == $url ) {
return $html;
}
return str_replace( $orig_url, $url, $html );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment