Created
March 30, 2012 14:30
-
-
Save norcross/2251926 to your computer and use it in GitHub Desktop.
Fix curly quotes on post save and display
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
function rkv_no_curly_display () { | |
// call the global | |
global $post; | |
// get the post content | |
$content = $post->post_content; | |
// clean it up | |
$original = array('“', '”', '’'); | |
$replaced = array('"', '"', '\''); | |
// now style and return it | |
return wpautop( str_replace($original, $replaced, $content) ); | |
} | |
add_filter('the_content', 'rkv_no_curly_display', 10); |
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
function rkv_no_curly_save( $content ) { | |
// call the global | |
global $post; | |
// get the content | |
$content = $post->post_content; | |
// clean it up | |
$original = array('“', '”', '’'); | |
$replaced = array('"', '"', '\''); | |
// now style and return it | |
return str_replace($original, $replaced, $content); | |
} | |
add_action('content_save_pre', 'rkv_no_curly_save'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment