WordPress links/bookmarks – need to urlencode because spaces are getting stripped

WordPress is stripping spaces out of links.

For example putting this into the web address of a new link:

Read More
mailto:my@email.com?subject=Hello there

and saving results in this:

mailto:my@email.com?subject=Hellothere

I know that a space is %20 but my clients can’t be expected to use this. Plus they may be uploading PDFs/Word documents with spaces in the filename and copying and pasting the link.

How can I remedy this? I know I have to use urlencode, however I don’t really want to edit the core wordpress admin, because on upgrading I’ll have to change it again. However, I will do if its the only way (having a look I can’t seem to find a hook or anything that will let me do this!), but I just can’t figure out where to put it.

Thanks for any/all help you can give me.

Related posts

Leave a Reply

1 comment

  1. You can use the antispambot() function for this.

    Example:

    <a href="<?php echo antispambot('mailto:my@email.com?subject=Hello there'); ?>">Some link text</a>