Make WordPress Core

Ticket #4298: 4298.2.diff

File 4298.2.diff, 1.5 KB (added by Denis-de-Bernardy, 15 years ago)

new patch on pre_ filters

  • wp-includes/default-filters.php

     
    7474        add_filter( $filter, 'balanceTags', 50);
    7575}
    7676
     77// Places to filter out newlines from html tags
     78$filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content', 'pre_term_description', 'pre_user_description', 'pre_link_description');
     79foreach ( $filters as $filter ) {
     80        add_filter( $filter, 'funky_html_fix', 1);
     81}
     82
    7783// Format strings for display.
    7884$filters = array('comment_author', 'term_name', 'link_name', 'link_description',
    7985        'link_notes', 'bloginfo', 'wp_title', 'widget_title');
  • wp-includes/formatting.php

     
    806806}
    807807
    808808/**
     809 * strip newline characters in html tags to prevent wpautop bugs
     810 *
     811 * @return void
     812 **/
     813
     814function funky_html_fix($text) {
     815        $text = str_replace(array("\r\n", "\r"), "\n", $text);
     816
     817        while ( preg_match("/<[^<>]*\n/", $text) )
     818                $text = preg_replace("/(<[^<>]*)\n+/", "$1", $text);
     819
     820        return $text;
     821} # funky_html_fix()
     822
     823/**
    809824 * Will only balance the tags if forced to and the option is set to balance tags.
    810825 *
    811826 * The option 'use_balanceTags' is used for whether the tags will be balanced.