Ticket #5604: formatting.php.5604.diff

File formatting.php.5604.diff, 0.8 kB (added by sunburntkamel, 8 months ago)

patch wp_trim_excerpt to strip style and script tags completely

  • wp-includes/formatting.php

    old new  
    816816                $text = get_the_content(''); 
    817817                $text = apply_filters('the_content', $text); 
    818818                $text = str_replace(']]>', ']]>', $text); 
     819                $search = array('@<script[^>]*?>.*?</script>@si',  // Strip out javascript 
     820                                '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly 
     821                                '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags 
     822                                '@<![\s\S]*?--[ \t\n\r]*>@'        // Strip multi-line comments including CDATA 
     823                ); 
     824                $text = preg_replace($search, '', $text); 
    819825                $text = strip_tags($text); 
    820826                $excerpt_length = 55; 
    821827                $words = explode(' ', $text, $excerpt_length + 1);