admin管理员组文章数量:1023876
I'm using the latest version of WordPress (3.1.1). Is it just me, or is WordPress now automatically linking plain-text email addresses?
I type [email protected]
as a comment and it shows up as <a href="mailto:[email protected]">[email protected]</a>
I am working on a plugin that filters comment text using the get_comment_text
filter and then subsequently modifies the presentation of the email address. This plugin worked fine before, but like I said, now WordPress automatically links email addresses.
I figured that WordPress would follow its own rules and do it by means of a filter, so I went ahead and added a priority level to my own filter of 9000
figuring that way I can force mine to trigger after WordPress is done sticking its nose in something that's not its business, but this did not work.
I'm wondering if anyone here knows a way around this situation, or at the very least, if someone knowledgeable about the system could point me to the source that is responsible for this automatic linking.
My plugin already has the functionality to work with plain-text emails, but this too is broken because after it modifies the presentation of the plain-text email, WordPress then goes and linkifies it.
EDIT: One Trick Poney pointed me to make_clickable
which is responsible for this. It's indeed added as a filter in wp-includes/default-filters.php
, with a priority of 9
. However, I have already tried, like I mentioned above, to set the priority level to 9000
to make my plugin work after WordPress has done its dirty business. This didn't work, is it because I'm getting the original unfiltered content? I figured I would be getting the filtered content (i.e. the content already linked).
So then I went ahead and activated the plain-text filter (which applies to plain-text emails), and applied it a priority of -9000
so that it gets in before make_clickable
, but again nothing good came of this because when make_clickable
did fire, it went ahead and figured it'd be a good idea to linkify the links I create. It 'linkifies' the urls in the href
attribute of a link, making for very messy output.
So it seems that the best thing to do would be to get in after wordpress has done its business, after make_clickable
has fired, but like I said for some reason even though I apply my filter a priority level of 9000
, compared to make_clickable
whose priority level is only 9
, nothing seems to happen. I will continue to investigate.
I can understand and imagine that WordPress devs were trying to be more user-friendly, but this seems to have caused some edge-case problems (ex. linkifying href attributes in already-existing links).
Any help would be greatly appreciated.
EDIT 2: Yep, I just tested my filter with a priority level of 9000, which I would imagine should run after WordPress ' make_clickable
whose priority level is 9. My filter gets the unaltered/unfiltered content. I don't know how or why this is happening. I would have imagined that having a later priority I would get the content as it had so far been altered by higher-priority filters, otherwise situations like these (collisions?) would arise, like this one.
I'm using the latest version of WordPress (3.1.1). Is it just me, or is WordPress now automatically linking plain-text email addresses?
I type [email protected]
as a comment and it shows up as <a href="mailto:[email protected]">[email protected]</a>
I am working on a plugin that filters comment text using the get_comment_text
filter and then subsequently modifies the presentation of the email address. This plugin worked fine before, but like I said, now WordPress automatically links email addresses.
I figured that WordPress would follow its own rules and do it by means of a filter, so I went ahead and added a priority level to my own filter of 9000
figuring that way I can force mine to trigger after WordPress is done sticking its nose in something that's not its business, but this did not work.
I'm wondering if anyone here knows a way around this situation, or at the very least, if someone knowledgeable about the system could point me to the source that is responsible for this automatic linking.
My plugin already has the functionality to work with plain-text emails, but this too is broken because after it modifies the presentation of the plain-text email, WordPress then goes and linkifies it.
EDIT: One Trick Poney pointed me to make_clickable
which is responsible for this. It's indeed added as a filter in wp-includes/default-filters.php
, with a priority of 9
. However, I have already tried, like I mentioned above, to set the priority level to 9000
to make my plugin work after WordPress has done its dirty business. This didn't work, is it because I'm getting the original unfiltered content? I figured I would be getting the filtered content (i.e. the content already linked).
So then I went ahead and activated the plain-text filter (which applies to plain-text emails), and applied it a priority of -9000
so that it gets in before make_clickable
, but again nothing good came of this because when make_clickable
did fire, it went ahead and figured it'd be a good idea to linkify the links I create. It 'linkifies' the urls in the href
attribute of a link, making for very messy output.
So it seems that the best thing to do would be to get in after wordpress has done its business, after make_clickable
has fired, but like I said for some reason even though I apply my filter a priority level of 9000
, compared to make_clickable
whose priority level is only 9
, nothing seems to happen. I will continue to investigate.
I can understand and imagine that WordPress devs were trying to be more user-friendly, but this seems to have caused some edge-case problems (ex. linkifying href attributes in already-existing links).
Any help would be greatly appreciated.
EDIT 2: Yep, I just tested my filter with a priority level of 9000, which I would imagine should run after WordPress ' make_clickable
whose priority level is 9. My filter gets the unaltered/unfiltered content. I don't know how or why this is happening. I would have imagined that having a later priority I would get the content as it had so far been altered by higher-priority filters, otherwise situations like these (collisions?) would arise, like this one.
1 Answer
Reset to default 2I noticed that wordpress' make_clickable
filter was attached to the comment_text
filter hook and not get_comment_text
, which is what I have been using for a while. I had researched earlier if this may be the case, specifically figuring out what the difference was between the two, and I think I read something about comment_text
using get_comment_text
, so maybe it was doing something more than once, resulting in the weird output I found.
I solved this by changing my filter to hook onto comment_text
instead, that way the priority would matter (duh), and kept my filter's priority level of 9000. Preliminary tests show everything to be working. This way I don't have to worry about wordpress modifying my output in unpredictable ways, instead I can just bother working with what wordpress vomits out. At least that way I know what I can work with and what I can't work with.
Thanks again to one trick pony for giving me a lead.
I'm using the latest version of WordPress (3.1.1). Is it just me, or is WordPress now automatically linking plain-text email addresses?
I type [email protected]
as a comment and it shows up as <a href="mailto:[email protected]">[email protected]</a>
I am working on a plugin that filters comment text using the get_comment_text
filter and then subsequently modifies the presentation of the email address. This plugin worked fine before, but like I said, now WordPress automatically links email addresses.
I figured that WordPress would follow its own rules and do it by means of a filter, so I went ahead and added a priority level to my own filter of 9000
figuring that way I can force mine to trigger after WordPress is done sticking its nose in something that's not its business, but this did not work.
I'm wondering if anyone here knows a way around this situation, or at the very least, if someone knowledgeable about the system could point me to the source that is responsible for this automatic linking.
My plugin already has the functionality to work with plain-text emails, but this too is broken because after it modifies the presentation of the plain-text email, WordPress then goes and linkifies it.
EDIT: One Trick Poney pointed me to make_clickable
which is responsible for this. It's indeed added as a filter in wp-includes/default-filters.php
, with a priority of 9
. However, I have already tried, like I mentioned above, to set the priority level to 9000
to make my plugin work after WordPress has done its dirty business. This didn't work, is it because I'm getting the original unfiltered content? I figured I would be getting the filtered content (i.e. the content already linked).
So then I went ahead and activated the plain-text filter (which applies to plain-text emails), and applied it a priority of -9000
so that it gets in before make_clickable
, but again nothing good came of this because when make_clickable
did fire, it went ahead and figured it'd be a good idea to linkify the links I create. It 'linkifies' the urls in the href
attribute of a link, making for very messy output.
So it seems that the best thing to do would be to get in after wordpress has done its business, after make_clickable
has fired, but like I said for some reason even though I apply my filter a priority level of 9000
, compared to make_clickable
whose priority level is only 9
, nothing seems to happen. I will continue to investigate.
I can understand and imagine that WordPress devs were trying to be more user-friendly, but this seems to have caused some edge-case problems (ex. linkifying href attributes in already-existing links).
Any help would be greatly appreciated.
EDIT 2: Yep, I just tested my filter with a priority level of 9000, which I would imagine should run after WordPress ' make_clickable
whose priority level is 9. My filter gets the unaltered/unfiltered content. I don't know how or why this is happening. I would have imagined that having a later priority I would get the content as it had so far been altered by higher-priority filters, otherwise situations like these (collisions?) would arise, like this one.
I'm using the latest version of WordPress (3.1.1). Is it just me, or is WordPress now automatically linking plain-text email addresses?
I type [email protected]
as a comment and it shows up as <a href="mailto:[email protected]">[email protected]</a>
I am working on a plugin that filters comment text using the get_comment_text
filter and then subsequently modifies the presentation of the email address. This plugin worked fine before, but like I said, now WordPress automatically links email addresses.
I figured that WordPress would follow its own rules and do it by means of a filter, so I went ahead and added a priority level to my own filter of 9000
figuring that way I can force mine to trigger after WordPress is done sticking its nose in something that's not its business, but this did not work.
I'm wondering if anyone here knows a way around this situation, or at the very least, if someone knowledgeable about the system could point me to the source that is responsible for this automatic linking.
My plugin already has the functionality to work with plain-text emails, but this too is broken because after it modifies the presentation of the plain-text email, WordPress then goes and linkifies it.
EDIT: One Trick Poney pointed me to make_clickable
which is responsible for this. It's indeed added as a filter in wp-includes/default-filters.php
, with a priority of 9
. However, I have already tried, like I mentioned above, to set the priority level to 9000
to make my plugin work after WordPress has done its dirty business. This didn't work, is it because I'm getting the original unfiltered content? I figured I would be getting the filtered content (i.e. the content already linked).
So then I went ahead and activated the plain-text filter (which applies to plain-text emails), and applied it a priority of -9000
so that it gets in before make_clickable
, but again nothing good came of this because when make_clickable
did fire, it went ahead and figured it'd be a good idea to linkify the links I create. It 'linkifies' the urls in the href
attribute of a link, making for very messy output.
So it seems that the best thing to do would be to get in after wordpress has done its business, after make_clickable
has fired, but like I said for some reason even though I apply my filter a priority level of 9000
, compared to make_clickable
whose priority level is only 9
, nothing seems to happen. I will continue to investigate.
I can understand and imagine that WordPress devs were trying to be more user-friendly, but this seems to have caused some edge-case problems (ex. linkifying href attributes in already-existing links).
Any help would be greatly appreciated.
EDIT 2: Yep, I just tested my filter with a priority level of 9000, which I would imagine should run after WordPress ' make_clickable
whose priority level is 9. My filter gets the unaltered/unfiltered content. I don't know how or why this is happening. I would have imagined that having a later priority I would get the content as it had so far been altered by higher-priority filters, otherwise situations like these (collisions?) would arise, like this one.
-
it's the
make_clickable
filter applied to comment_text. add your filter with-9000
priority or something like that – onetrickpony Commented Apr 18, 2011 at 5:19 - Thanks One Trick Pony I appreciate it! I was just finding out that it's not limited to email addresses, that it also applies to URLs. I'll investigate. If it works out I'll let you know in case you want to make this an answer. – Jorge Israel Peña Commented Apr 18, 2011 at 5:31
- I've added more information to my post in case you might have any ideas. – Jorge Israel Peña Commented Apr 18, 2011 at 5:51
1 Answer
Reset to default 2I noticed that wordpress' make_clickable
filter was attached to the comment_text
filter hook and not get_comment_text
, which is what I have been using for a while. I had researched earlier if this may be the case, specifically figuring out what the difference was between the two, and I think I read something about comment_text
using get_comment_text
, so maybe it was doing something more than once, resulting in the weird output I found.
I solved this by changing my filter to hook onto comment_text
instead, that way the priority would matter (duh), and kept my filter's priority level of 9000. Preliminary tests show everything to be working. This way I don't have to worry about wordpress modifying my output in unpredictable ways, instead I can just bother working with what wordpress vomits out. At least that way I know what I can work with and what I can't work with.
Thanks again to one trick pony for giving me a lead.
本文标签: plugin developmentWordPress is automatically linking plain text email addresses
版权声明:本文标题:plugin development - WordPress is automatically linking plain text email addresses 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745603830a2158613.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
make_clickable
filter applied to comment_text. add your filter with-9000
priority or something like that – onetrickpony Commented Apr 18, 2011 at 5:19