admin管理员组

文章数量:1279112

I found out there is a plugins for ticket support. It uses the WordPress comments functions in the ticket system reply.

The issue is the plugin will not accept a line break or with <br.>. How can I make it to accept the <br.> tag or lines break?

                <div class="reply_form">
                    <?php
                    $comments_args = array(
                        'title_reply' => __('Reply', 'orbisius_support_tickets'),
                        'title_reply_to' => '',
                        'label_submit' => __('Send', 'orbisius_support_tickets'),
                        'comment_notes_after' => '',
                        'comment_notes_after' => '',
                        'comment_notes_before' => '',
                        'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . '</label> <textarea id="comment" name="comment" cols="45" rows="5" maxlength="65525" required="required"></textarea></p>',
                    );

Here is the plugin if you are interested.

Live Demo Website with the plugin installed:
/?orbisius_support_tickets_data%5Bticket_id%5D=51

Line-break applied. After Submit, the line-break are not working.

I found out there is a plugins for ticket support. It uses the WordPress comments functions in the ticket system reply.

The issue is the plugin will not accept a line break or with <br.>. How can I make it to accept the <br.> tag or lines break?

                <div class="reply_form">
                    <?php
                    $comments_args = array(
                        'title_reply' => __('Reply', 'orbisius_support_tickets'),
                        'title_reply_to' => '',
                        'label_submit' => __('Send', 'orbisius_support_tickets'),
                        'comment_notes_after' => '',
                        'comment_notes_after' => '',
                        'comment_notes_before' => '',
                        'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . '</label> <textarea id="comment" name="comment" cols="45" rows="5" maxlength="65525" required="required"></textarea></p>',
                    );

Here is the plugin if you are interested.
https://we.tl/t-iLFfJ3wKxH

Live Demo Website with the plugin installed:
https://qwq.rf.gd/?orbisius_support_tickets_data%5Bticket_id%5D=51

Line-break applied. After Submit, the line-break are not working.

Share Improve this question edited Oct 9, 2021 at 17:05 Liang asked Oct 9, 2021 at 16:54 LiangLiang 156 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

On orbisius-support-tickets/modules/core/cpt.php file the comment is sanitised as a single-line input with the function sanitize_text_field() which removes the line breaks. For a textarea field WordPress has sanitize_textarea_field();

Ref: https://developer.wordpress/reference/functions/sanitize_textarea_field/

On that file, you can find the line

 $comment = sanitize_text_field( wp_strip_all_tags( $_POST['comment'] ) );

And replace it with:

$comment = sanitize_textarea_field( wp_strip_all_tags( $_POST['comment'] ) );

本文标签: Plugins ignored a line breaks or ltbrgt tag in the WordPress comment functions