Last active
March 22, 2018 07:15
-
-
Save bfintal/9c905560a3c897520400a4222966288a to your computer and use it in GitHub Desktop.
This file contains 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_action( 'pbs_pre_save_content', 'pre_fix_ampersand_permalink' ); | |
global $is_saving; | |
$is_saving = false; | |
function pre_fix_ampersand_permalink() { | |
global $is_saving; | |
$is_saving = true; | |
} | |
add_action( 'pbs_saved_content', 'fix_ampersand_permalink', 999 ); | |
function fix_ampersand_permalink( $post_id ) { | |
global $is_saving; | |
if ( $is_saving ) { | |
$possibly_wrong_perma = esc_url( get_permalink( $post_id ) ); | |
die( preg_replace( '/&?#038;/', '&', $possibly_wrong_perma ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment