Created
November 14, 2013 14:14
-
-
Save tott/7467467 to your computer and use it in GitHub Desktop.
Enforce domain mapping mapped domain for all front-end urls ran through esc_url()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'clean_url', 'sav_force_mapped_url' ); | |
| function sav_force_mapped_url( $url ) { | |
| if ( ! is_admin() ) { | |
| if ( function_exists( 'get_original_url' ) && strpos( '/wp-admin', $url ) === false ) { | |
| $original = preg_replace( '#^https?://#', '', get_original_url('') ); | |
| $new = preg_replace( '#^https?://#', '', site_url() ); | |
| $url = str_ireplace( $original, $new, $url ); | |
| } | |
| } | |
| return $url; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment