Exclude in sanitization

Support Meta Box AIO Exclude in sanitizationResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47963
    PTPT
    Participant

    Hi,

    When adding the text fields, is there a way that I can exclude the "<br>" code from the sanitization?
    I don't want to disable the sanitization completely. I just want a way to break lines. Can it be done? If so, how?
    Thanks.

    #47968
    PeterPeter
    Moderator

    Hello,

    You can use the bypass sanitization and add the <br> tag to the text field again. Following the documentation https://docs.metabox.io/sanitization/#bypass-the-sanitization

    #47983
    PTPT
    Participant

    It worked with the following function. In case anyone need it.

    function sanitize_text_with_br($input) {
    // Define allowed HTML tags
    $allowed_html = array(
    'br' => array(),
    );

    // Sanitize the input while allowing <br> tags
    return wp_kses($input, $allowed_html);
    }

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.