0

I've been using tel: links in Custom Menus combined with Responsive Design to add a "Call Now" button to my themes for smartphones. It's been working well. A client just asked me to also add a "Send Text" button. I thought I would use sms: which seems to have passable device support.

However, WordPress is stripping it out of the URL when I save the menu. After research, I concluded it has something to do with esc_url() and/or wp_kses() (see Trac ticket #18268). I concocted the following code in an effort to add the SMS protocol myself and put in it functions.php:

<?php
function add_new_protocol() {
    global $protocols;
    $new_protocols = array( 'sms' );

    return array_merge( $protocols, $new_protocols );
}
add_filter('pre_kses', 'add_new_protocol');
?>

It didn't work :) This was a bit of a shot in the dark; I'm still pretty green at using filters etc. I would love a pointer on the correct method for adding new protocols to Wordpress for use in Custom Menus.

0

You need to use the kses_allowed_protocols filter:

function wpse_allow_sms_protocol( $protocols ) {
    $protocols[] = 'sms';
    return $protocols;
}

add_filter( 'kses_allowed_protocols', 'wpse_allow_sms_protocol' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.