Created
February 21, 2019 21:35
-
-
Save bacoords/e838006c36fcb6aad80ef022a7824082 to your computer and use it in GitHub Desktop.
Replaces smart quotes with quotation marks when adding shortcodes to WordPress content
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
/** | |
* 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