WordPress.org

Ready to get started?Download WordPress

Forums

remove autop from wp_richedit_pre filter (6 posts)

  1. crmb
    Member
    Posted 9 months ago #

    not sure how i can modify/replace the function "wp_richedit_pre" from formatting.php to remove this (line 2539 with 3.6.1)
    $output = wpautop($output);

    I ask TinyMCE Advanced to keep my p/br tags, and it works (they are stored in the DB) but the autop mess them while post_content reloaded in the editor

    Thank you

  2. crmb
    Member
    Posted 9 months ago #

    Actually just removing this line from wpautop function (formatting.php) may be enough
    $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);

    Then, no need to remove wpautop
    But of course i don't want to edit core files

  3. esmi
    Forum Moderator
    Posted 9 months ago #

    Stop editing WordPress core files then.

  4. crmb
    Member
    Posted 9 months ago #

    sorry i didn't make myself clear.
    Actually my question was how to overwrite functions of core files without modifying core file
    Is it actually possible ?

  5. esmi
    Forum Moderator
    Posted 9 months ago #

    You could try adding a filter to richedit_pre. Something like:

    function my_richedit_pre($text) {
    	if ( empty($text) ) return $text;
    	$output = strip_tags($text);
    	[ do more stuff? ]
    }
    add_filter('richedit_pre', 'my_richedit_pre');

    might get you started but bear in mind that I've not tried this out myself.

  6. bcworkz
    Member
    Posted 9 months ago #

    Core functions cannot be modified, with the exception of pluggable functions, mostly defined in pluggable.php. All modifications of the way WP operates must be done via filter and action hooks. Doing anything else leads down a dangerous path.

Reply

You must log in to post.

About this Topic