Line breaks in CSS getting wrapped in paragraphs
- This topic has 10 replies, 4 voices, and was last updated 7 months ago by
Oscar Domingo Mateo Oro.
-
AuthorPosts
-
May 24, 2023 at 11:36 PM #41926
brandonjp
ParticipantHello, I'm having a new issue that might be related to WP core updates. Inside of a View, when I have an empty line in the CSS, the
<style>
element output will contain paragraphs<p>
Here's an example image: https://cln.sh/C8ltv8fS
Removing line breaks in the CSS does resolve the problem, but previously the line breaks did not cause a problem. I'm not sure when this started but I know it started within the past 3 months.
I am currently on:
WordPress Version 6.2.2
Meta Box Version 5.7.1
Meta Box AIO Version 1.20.3May 24, 2023 at 11:48 PM #41927brandonjp
ParticipantLooks like it's happening on Javascript code too: https://cln.sh/CwJkMz3b
May 25, 2023 at 7:59 PM #41933Peter
ModeratorHello,
Can you please share a screenshot of the CSS code in the view area? I do not see that issue on my demo site, screenshots
Backend: https://monosnap.com/file/xDDz911PpwHKDlJpJ5x87pjMOn7Rjz
Frontend: https://monosnap.com/file/I7mWRYSpphUN4C2LM2vxGXLEIyT4E4May 25, 2023 at 10:52 PM #41938brandonjp
ParticipantHi Peter - Thanks for the reply.
Here are a couple screenshots...
Backend: https://cln.sh/xBT8XnWg
Frontend: https://cln.sh/y5P0j9d8I'm having this problem on a few sites. But I have a couple sites that are not having this problem. So my next guess is that it might be a conflicting plugin or theme issue. I will check into that next.
But if you have any other ideas, let me know. Thank you!
May 26, 2023 at 5:38 PM #41944Peter
ModeratorHello,
Ok, please try to disable all plugins except Meta Box, MB AIO and switch to a standard theme of WordPress then check this issue again.
Let me know how it goes.
June 10, 2023 at 12:17 AM #42145brandonjp
ParticipantHi Long & Peter-- I can confirm and add a little more info...
* Using the plain WP Twenty-Twenty-Two theme and only Meta Box & AIO enabled
* When MB View shortcode is placed in a template using full site editor
* any line breaks in CSS or JS inside the MB View get wrapped in paragraph P tagsScreenshot of the View CSS: https://cln.sh/5JNmwclk
Screenshot of the rendered html: https://cln.sh/gHYQNqVTIf the shortcode is used inside another View or placed in a post using block editor, it works correctly. The bug only happens when the short code is added to a template (Single, Archive) or template part (Header, Footer)
So far, I have noticed this issue on at least 6 sites. All are using the latest versions of Meta Box and AIO. Some sites are on WP v6.1.3 and some are WP v6.2.2. All are using FSE Block Themes, but the theme doesn't seem to make a difference: some are using the Twenty Twenty Two, some Twenty-Twenty-Three theme or other FSE themes.
Also, I think this change happened sometime before May 24, that's when my client first noticed the styles not loading. But it might have happened a long time before that.
June 12, 2023 at 8:26 PM #42163Peter
ModeratorHello,
I can reproduce the issue with the FSE (Full Site Editing). I've escalated this issue to the development team to fix this issue in the next update.
June 13, 2023 at 12:43 PM #42176Anh Tran
KeymasterHi Brandon,
Thanks for your feedback. After investigating, I found that there was a change in WP:
Previously, the block template was parsed in the following orders:
do_blocks
, thenshortcode_unautop
, thendo_shortcode
. But this order was changed in these 2 commits:https://github.com/WordPress/WordPress/commit/6a077b35f15590a843ff8a6c97a135f3a34872dd
https://github.com/WordPress/WordPress/commit/2bb3a5169548d16173cf48ca9da1111efc428f86So the order now is
shortcode_unautop
,do_shortcode
, thendo_blocks
.The problem is that the MB Views shortcode in the block template is the
core/shortcode
block, which applieswpautop
(I have no idea why do they do that):https://github.com/WordPress/WordPress/blob/master/wp-includes/blocks/shortcode.php
So, when parsing the a block template, the MB Views shortcode is parsed first (via
do_shortcode
), and then is appliedwpautop
(viado_blocks
withcore/shortcode
block), and that causes the problem. Previously, theydo_blocks
first, and thendo_shortcode
, then it didn't happen.As this is in the WordPress core, e.g. after the content of views are rendered, I think the only way to resolve it is removing line brakes in the plugin. This is what I'll do in the next version, so you don't have to do that manually.
June 13, 2023 at 2:03 PM #42178Anh Tran
KeymasterAfter doing some research, I found that this is a big issue in WP itself, and is still being discussed!
September 16, 2024 at 5:45 PM #46465Oscar Domingo Mateo Oro
ParticipantHi, i have a problem that I think is related to this: line breaks in the template tab appear as "<br>" in the generated HTML for the page.
{% for key, term, url in terms %}
{{ term.name }}
{% endfor %}==>
<a class="GC_etiqueta_localizacion" href="https://qqqq.com/loc/abrucena/">Abrucena</a><br>
Adra<br>
September 16, 2024 at 5:49 PM #46466Oscar Domingo Mateo Oro
ParticipantSorry for the formating...
{% for key, term, url in terms %} <a class="GC_etiqueta_localizacion" href="{{ term.url }}">{{ term.name }}</a> {% endfor %}
results in
<a class="GC_etiqueta_localizacion" href="https://qqq.com/loc/abrucena/">Abrucena</a><br> <a class="GC_etiqueta_localizacion" href="https://qqq.com/loc/adra/">Adra</a><br>
-
AuthorPosts
- You must be logged in to reply to this topic.