Stop WordPress (Or any CMS) sanitizing input

When editing website CMS settings, is there a way to tell the CMS to not sanitize the input? The website in question contains a call-to-action (CTA) on the front page with an input. See picture:

enter image description here

Read More

See that I added the <br /> tag to ad a line break between the email and phone number. This is because the result as is is a long CTA, I’d like to split it into two lines. But the output ignores the tag:

<div class="front-call-to-action">
                <a class="front-button" href="mailto:myname@example.com" >

                        Tel: 123.456.7891  myname@example.com                   </a>
            </div>

I’m aware that I could use editor to hard edit the output but wondered if there was a special character of some sort that I can use to tell the CMS to output the tag, rather than ignore it?

Note that this is distinct from the standard CMS back end where an admin would enter text and could edit using “raw html” input in the text input. This concerns the website set up input.

Related posts

Leave a Reply

1 comment

  1. My answer then is going to be – don’t do it that way at all.

    Have two input fields, one for telephone number and one for email address. Here’s how I normally do it below, in this case I’ve used option tree for the options, but pulling the data out of the option isn’t the issue, it’s what you do after;

    <?php
        $mainTel = ot_get_option('hq_tel_number');
        $mainEmail = ot_get_option('hq_email');
    
        $encodedEmailLink = encode_email('mailto:'. $mainEmail);
        $encodedEmail = encode_email($mainEmail);
    ?>
    
    <div class="grid_4">
        <ul class="contact-info">
            <li class="number"><a href="tel:<?php echo $mainTel; ?>"><?php echo $mainTel; ?></a></li>
            <li class="email"><a href="<?php echo $encodedEmailLink; ?>"><?php echo $encodedEmail; ?></a></li>
        </ul>
    </div>
    

    So the fact that it’s split means I can form a link with the telephone number that will work on smartphones, the number can be clicked on to call it. You can style them both differently and appropriately and the email address rather than just getting output to screen for all and sundry to scrape at least gets obfuscated a little bit using this function in functions.php

    /* FUNCTION TO ASCII ENCODE EMAIL ADDRESSES  ------------------------------------------------------------*/
    
    function encode_email($e) {
      for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
      return $output;
    }