Opened 12 years ago
Last modified 4 months ago
#26868 new enhancement
Function 'make_clickable()' doesn't make hyperlinks from explicit URLs using the `mailto:`, `tel:` and other schemes that do not start with `//`
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.8 |
| Component: | Formatting | Keywords: | needs-unit-tests needs-testing needs-refresh 2nd-opinion |
| Focuses: | Cc: |
Description
Function make_clickable() tries to recognise URLs and convert these into clickable hyperlinks. The function is by default configured as a filter for comment text.
Unfortunately, the function assumes that all explicitly declared URLs begin with the string // after the scheme and colon parts which is not the case for the mailto:, tel: and many other schemes. Such URLs could usefully be made clickable, especially for use on smartphones and tablets.
This also leads to inconsistencies between explicitly and implicitly declared URLs. For example, the string myemail@mydomain.com is converted into a clickable hyperlink whilst the string mailto:myemail@mydomain.com is not.
By contrast, the TinyMCE post editor correctly and automatically makes both implicit and explicit mailto: links clickable but does nothing with tel:.
For reference, the syntax of URLs is defined by http://tools.ietf.org/html/std66, the mailto: scheme by http://tools.ietf.org/html/rfc6068 and that for tel: by http://tools.ietf.org/html/rfc3966.
As #16892 has illustrated, parsing URLs can be hard. The use of wp_allowed_protocols() may help in detecting which strings we wish to make clickable.
Found whilst testing #22946.
Attachments (1)
Change History (7)
#1
@
12 years ago
- Keywords needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
- Type changed from defect (bug) to enhancement
@
12 years ago
This makes the trailing optional. This is by no means a full solution, as it would allow http:example.com, but works as a good workaround to allow mailto: and friends, while still maintaining the same functionality
#2
@
12 years ago
The correct comment above:
This makes the trailing // optional. This is by no means a full solution, as it would allow http:example.com, but works as a good workaround to allow mailto: and friends, while still maintaining the same functionality
#5
@
5 months ago
Hey All,
Just taking a look into this now and can confirm the issue around phone numbers not converting to hyperlinks is still present, as well as emails that start with mailto:. I think the email one is less of an issue, as passing in any email will have it automatically converted to a hyperlink and I am not sure how often people will be placing a leading mailto: into their copy.
However, going back to the issue around phone numbers, I am not sure how easy this issue will be to fix, but also I am not sure if it needs to be? For example if someone was to use a large number in their copy to show off a particular statistic, etc. then having this auto convert to a link without any control over this would be at the detriment of the post content. I personally think this is fine as is, and has been long standing enough within WP that it might be more frustrating to the end users implementing a change to this now at this stage.
But I am keen to get more input here from others in the community, as I think we can ultimately just close this ticket, but others may disagree and before doing so it would be good to hear back. 😃
#6
@
4 months ago
- Keywords needs-refresh 2nd-opinion added; dev-feedback removed
The block editor makes it easy to make links out of telephone numbers and emails: select the text you want linked, click the Link icon in the toolbar, and it does it automatically without you having to prepend mailto or tel.
The question is should make_clickable() link these things when used programmatically. If I were using it personally, I would like it to do that, otherwise it feels like it doesn't live up to its name. Requesting a second opinion.
I think this would be cool if it doesn't have performance issues.
That said, make_clickable() isn't currently designed to work this way, so it's safe to classify this as an enhancement.