Contact Form 7: textareaタグのwrap="hard"が有効にならない
-
ContactForm7 1行に1000文字以上あると文字化け
https://ja.forums.wordpress.org/topic/11182?replies=5にあるように、改行なしで長文が投稿されるケースが時々あり困っております。
とりあえず回避するため、
textareaタグに「wrap=”hard”」を追加して改行を入れるように試してみたのですが
送信されてくるメールでは改行が入っておらず、
約500文字(全角)で強制的に改行が入って文字化けしてしまいます。方法は、functions.phpに以下を追加し、
HTMLソースには wrap=”hard”が追加されていることは確認できています。原因か代替案があればご教示いただけますと助かります。
add_action( 'wpcf7_init', 'my_wpcf7_add_shortcode_textarea' ); function my_wpcf7_add_shortcode_textarea() { wpcf7_add_shortcode( array( 'textarea', 'textarea*' ), 'my_wpcf7_textarea_shortcode_handler', true ); } function my_wpcf7_textarea_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); if ( empty( $tag->name ) ) return ''; $validation_error = wpcf7_get_validation_error( $tag->name ); $class = wpcf7_form_controls_class( $tag->type ); if ( $validation_error ) $class .= ' wpcf7-not-valid'; $atts = array(); $atts['cols'] = $tag->get_cols_option( '40' ); $atts['rows'] = $tag->get_rows_option( '10' ); $atts['maxlength'] = $tag->get_maxlength_option(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); if ( $tag->has_option( 'readonly' ) ) $atts['readonly'] = 'readonly'; if ( $tag->is_required() ) $atts['aria-required'] = 'true'; $atts['aria-invalid'] = $validation_error ? 'true' : 'false'; $value = (string) reset( $tag->values ); if ( '' !== $tag->content ) $value = $tag->content; if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) { $atts['placeholder'] = $value; $value = ''; } if ( wpcf7_is_posted() && isset( $_POST[$tag->name] ) ) $value = stripslashes_deep( $_POST[$tag->name] ); $atts['name'] = $tag->name; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<span class="wpcf7-form-control-wrap %1$s"><textarea wrap="hard" %2$s>%3$s</textarea>%4$s</span>', $tag->name, $atts, esc_textarea( $value ), $validation_error ); return $html; }
1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
- トピック「Contact Form 7: textareaタグのwrap="hard"が有効にならない」には新たに返信することはできません。