daomapsieucap/fiber-admin

Convert Email Text to Link conflicts with content in data attribute

daomapsieucap opened this issue · 3 comments

Convert Email Text to Link now converts all content using hook the_content which makes the wrong HTML structure in the data- attribute.

To prevent this issue, I think the feature Convert Email Text needs to use regex to prevent converting text in the data- attribute.

Suggest solutions:

@daomapsieucap Have issue convert email with regex.
When element with a email structure attribute, and only 1 element is added on page. All content will not be wrapped with <p> tag. So $att_email_regex regex not work.
When there are more than 2 elements, all content will be wrapped with <p> tag. But there is a problem if the element has more attributes, the regex doesn't work correctly

content-01

content-03
content-02

When the regex doesn't work correctly, the email structure attribute will be replaced with email link. Lead to incorrect email extraction results.

convert-is-wrong-attribute-1
convert-is-wrong-attribute-2
convert-is-wrong-attribute

I updated my code for function fiad_auto_convert_email_address. Demo on the lab site with Team List component. Please see demo on test bug convert email page and revise my code on the Lab site.

Link test Regex and preg_match:

https://regex101.com/r/1jhgsF/1
https://www.phpliveregex.com/p/IfC

@phongkhuu115 Could you help to check the case mentioned above?