How to add wechat (weixin) link to navigation menu?

The profile link of WeChat (or Weixin) has the following format: weixin://contacts/profile/username

As you can see, it doesn’t use http:// and that seems to be the reason that it cannot be added to the WordPress navigation menu.

Well you can add it, but after saving the menu, the URL field is blank (again).

The strangest thing is that the navigation menu does not exclusively save http(s); I just tried to save a telephone number URL (tel:00861012345678) and that is actually saved.

Is there any way to get the WeChat link to properly show?

Thanks.

Solutions Collecting From Web of "How to add wechat (weixin) link to navigation menu?"

Filter kses_allowed_protocols (wp-includes/functions.php wp_allowed_protocols) to add your protocol:

add_filter( 'kses_allowed_protocols', function( $protocols ) {
    $protocols[] = 'weixin';
    return $protocols;
});

The default values are ‘http’, ‘https’, ‘ftp’, ‘ftps’, ‘mailto’, ‘news’, ‘irc’, ‘gopher’, ‘nntp’, ‘feed’, ‘telnet’, ‘mms’, ‘rtsp’, ‘svn’, ‘tel’, ‘fax’, and ‘xmpp’.