Skip to content

Instantly share code, notes, and snippets.

@norcross
Created March 30, 2012 14:30
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 norcross/2251926 to your computer and use it in GitHub Desktop.
Save norcross/2251926 to your computer and use it in GitHub Desktop.
Fix curly quotes on post save and display
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);
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