Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created October 15, 2014 18:02
Show Gist options
  • Save sidharrell/71f01924d56d460c11a4 to your computer and use it in GitHub Desktop.
Save sidharrell/71f01924d56d460c11a4 to your computer and use it in GitHub Desktop.
replace comma tags in answers in visible (but not hidden) text
add_filter ( 'the_content', 'who_cares_about_an_oxford_comma', 11 );
function who_cares_about_an_oxford_comma ( $content ) {
$base = '#(<span.*)\{comma}(.*</span>)#';
$replace = '$1,$2';
$new_content = "";
while (($new_content = preg_replace( $base, $replace, $content )) != $content) {
$content = $new_content;
}
return $new_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment