Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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' );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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