How to allow a JS snippet as the input for a custom field?

Support General How to allow a JS snippet as the input for a custom field?Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23408
    RickRick
    Participant

    Hey,

    I've searched everywhere that I can find, but can't find a solution. Is there a way to have a custom field that allows the user to input a code snippet?

    I've tried WYSIWYG and can input simple html like <p> etc, but as soon as I put <script> or <iframe> it gets stripped out. Is there a way to do it? I'd like a field where the user can enter their embed code from a video site.

    Thanks,
    Rick

    #23412
    Long NguyenLong Nguyen
    Moderator

    Hi Rick,

    To ensure the user input is safe to save to the database, Meta Box provides a mechanism to sanitize fields’ values. The default sanitized callback for the field WYSIWYG is wp_kses_post. You can use a custom sanitize callback or bypass the sanitization by following this documentation https://docs.metabox.io/sanitization/#bypass-the-sanitization.

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