• Resolved ODAK71

    (@odak71)


    Contact Form 7 ist great, very great, but there is one problem since a longer time and I write you the problem and spent you money, but the problem exists anymore.

    I use Contact form 7 to send HTML-Emails with good-looking, more complex HTML.

    The problem is this autop on line 284 in includes / classes.php:

    if ( $use_html ) {
                           $body = preg_replace_callback( $regex, $callback_html, $mail_template['body'] );
                           $body = wpautop( $body ); // <---
                   } else {
                           $body = preg_replace_callback( $regex, $callback, $mail_template['body'] );
                   }

    I must uncomment this line on every plugin update – and because you are very hard-working there are a lot of updates and I have more than one Blog.

    The p’s destroy my HTML-structure.

    Please make this line hookable or depending on WPCF7_AUTOP – this is simple and help me and a lot of other WP CF 7 users who wants making more complex HTML-Email-Layouts.

    And here is the code-replacement:

    if ( $use_html ) {
                           $body = preg_replace_callback( $regex, $callback_html, $mail_template['body'] );
                           if ( WPCF7_AUTOP ) {
                               $body = wpautop( $body );
                           }
                   } else {
                           $body = preg_replace_callback( $regex, $callback, $mail_template['body'] );
                   }

    http://ww.wp.xz.cn/extend/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    <?php
    
    add_filter( 'wpcf7_mail_components', 'dontautop_wpcf7_mail_components', 10, 2 );
    
    function dontautop_wpcf7_mail_components( $components, $contact_form ) {
    	$mail_template = $contact_form->mail;
    
    	$regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/';
    
    	$use_html = (bool) $mail_template['use_html'];
    
    	$callback = array( &$contact_form, 'mail_callback' );
    	$callback_html = array( &$contact_form, 'mail_callback_html' );
    
    	if ( $use_html )
    		$body = preg_replace_callback( $regex, $callback_html, $mail_template['body'] );
    	else
    		$body = preg_replace_callback( $regex, $callback, $mail_template['body'] );
    
    	$components['body'] = $body;
    
    	return $components;
    }
    
    ?>

    Add this into your theme’s functions.php.

    Thread Starter ODAK71

    (@odak71)

    Thanx!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Contact Form 7] complex HTML-email autop’ is closed to new replies.