| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 | // Function to replace straight single quotes with curly single quotes in HTML content
function replace_straight_single_quotes_with_curly($content) {
    // Regular expression to match text nodes within HTML content
    $pattern = '/(?<=>)([^<]+)(?=<)/';
 
    // Replace straight single quotes with curly single quotes in text nodes
    $content = preg_replace_callback($pattern, function($matches) {
        return str_replace("'", "", $matches[0]);
    }, $content);
 
    return $content;
}
 
// Hook to filter the_content
add_filter('the_content', 'replace_straight_single_quotes_with_curly');
 
// Hook to filter the_excerpt (if needed)
add_filter('the_excerpt', 'replace_straight_single_quotes_with_curly'); | 
Partager