Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2011 20:12
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 anonymous/1215001 to your computer and use it in GitHub Desktop.
Save anonymous/1215001 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Domain Mapping Upgrades
Plugin URI:
Description: Upgrade to Domain Mapping plugin
Version: 0.1
Author: Chris Morrell
Author URI: http://cmorrell.com
*/
function dm_filter_site_url($url, $path, $scheme, $blog_id)
{
if ($blog_id) {
return $url;
}
if (in_array($scheme, array('login_post', 'login', 'admin')) && get_site_option(' dm_redirect_admin', false)) {
$orig_url = trailingslashit(get_original_url( 'siteurl' ));
$site_url = trailingslashit(get_option( 'siteurl' ));
if ($orig_url != $site_url) {
if ( !in_array($scheme, array('http', 'https')) ) {
if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
$scheme = 'https';
elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )
$scheme = 'https';
elseif ( ('admin' == $scheme) && force_ssl_admin() )
$scheme = 'https';
else
$scheme = ( is_ssl() ? 'https' : 'http' );
}
$orig_url = parse_url($orig_url);
$url = $scheme . '://' . $orig_url['host'] . '/' . $path;
}
}
return $url;
}
add_filter( 'site_url', 'dm_filter_site_url', 20, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment