简体   繁体   English

如何在WYSIWYG编辑器中使用方括号对文本进行后处理?

[英]How to use square brackets in a WYSIWYG editor to post-process text?

I need to obfuscate email addresses before they are published on my users' sites, to prevent spambots from scraping them. 我需要先对电子邮件地址进行混淆处理,然后再将其发布在用户的网站上,以防止垃圾邮件抓取程序将其抓取。 However, some users like to use mailto links (against my advice, but they do what they will), and my obfuscation function breaks the mailtos. 但是,有些用户喜欢使用mailto链接(根据我的建议,但是他们会做他们将做的事情),而我的混淆功能破坏了mailtos。 So I'd like to make it easy for site admins to slap obfuscation around some email addresses but not others. 因此,我希望站点管理员可以轻松地对某些电子邮件地址进行混淆处理,而对其他电子邮件地址不加处理。

I want to use syntax like this: 我想使用这样的语法:

"Some text, some more text, an [emailaddress@example.com], and more text."

Which will output 将输出

"Some text, some more text, an emailaddress<span class='obfuscate' style='display:none;'>@</span>example.com, and more text."

Is there a standard way to get PHP to evaluate and process only the text in the square brackets? 有没有一种标准方法可以使PHP仅评估和处理方括号中的文本? I've seen similar notation in Wordpress code, for example, 例如,我在Wordpress代码中看到过类似的符号,

[contact-form-7] 

is typed in the WYSIWYG editor, and will be rendered as a fully formed contact form to the public. 在所见即所得(WYSIWYG)编辑器中键入,并将作为完整的联系表呈现给公众。 So how can I do that? 那我该怎么办呢?

我使用了以下正则表达式:[[\\ w。] + @ [\\ w] +。[\\ w] +]查找括在方括号中的电子邮件地址,并将其替换为混淆后的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM