Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created February 21, 2019 21:35
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 bacoords/e838006c36fcb6aad80ef022a7824082 to your computer and use it in GitHub Desktop.
Save bacoords/e838006c36fcb6aad80ef022a7824082 to your computer and use it in GitHub Desktop.
Replaces smart quotes with quotation marks when adding shortcodes to WordPress content
/**
* Scrubs content for curly quotes
* @param string $content
* @return string
*/
function prefix_scrub_smart_quotes_from_shortcodes( $content ){
// Search for all smartquotes inside of shortcodes and replace them
$content = preg_replace('/(“|”)(?=[^\[]*\])/', '"', $content );
return $content;
}
add_filter( 'content_save_pre', 'prefix_scrub_smart_quotes_from_shortcodes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment