Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The HTML within a paragraph gets converted into a translation string on theme save #573

Open
pshemek opened this issue Apr 19, 2024 · 2 comments

Comments

@pshemek
Copy link

pshemek commented Apr 19, 2024

I ended up with:

<!-- wp:paragraph {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}}} -->
<p style="font-style:normal;font-weight:500">
<?php echo __('<a href="mailto:email@example.com" data-type="mailto" data-id="mailto:email@example.com">email@example.com</a><br>Tel.: +48 000 000 000', 'mytheme');?>
</p>
<!-- /wp:paragraph -->

while the more desirable would be:

<!-- wp:paragraph {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}}} -->
<p style="font-style:normal;font-weight:500">
<a href="mailto:email@example.com" data-type="mailto" data-id="mailto:email@example.com"><?php echo __('email@example.com', 'mytheme'); ?></a><br><?php echo __('Tel.: +48 000 000 000', 'mytheme');?>
</p>
<!-- /wp:paragraph -->

I am aware it may be difficult to implement, but I'm just reporting the situations when I was forced to edit the generated template or pattern manually to make it deliverable.

I'm not even sure that every paragraph should be converted into a translation, but I have no idea how we could distinguish between the ones we want and the ones we don't.

@pbking
Copy link
Contributor

pbking commented Apr 19, 2024

Oh, great example! Thanks for logging.

Yes, I can see how this could be improved to ensure that it's only the content of elements (and not the entire nested elements) that need to be escaped.

@creativecoder
Copy link
Contributor

It looks like WP_HTML_Tag_Processor doesn't yet support parsing or operating on child nodes, unfortunately, which would make this easier to solve. But I do believe that functionality is planned for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants