最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - Line Breaks are stripped off when direction property is found

programmeradmin2浏览0评论

The line breaks are stripped off when the p tag has a dir attribute inserted, to explain further I'll list some examples.

Let's say we have 2 lines of text as following

<p>Text Paragraph Number One Goes Here</p>
<p>Text Paragraph Number Two Goes Here</p>

If I want to add line breaks between the two paragraphs it works fine to become like:

<p>Text Paragraph Number One Goes Here</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Text Paragraph Number Two Goes Here</p>

However if the paragraphs have a dir attribute as below

<p dir="ltr">Text Paragraph Number One Goes Here</p>
<p dir="ltr">Text Paragraph Number Two Goes Here</p>

All <p dir="ltr">&nbsp;</p> are removed and no line breaks are inserted.

The site has TinyMCE plugin which has an option to keep paragraph tags in the Classic block and the Classic Editor but this didn't solve the problem. I disabled the plugin and also didn't resolve the issue.

And also I added the wpautop hook in functions

  remove_filter( 'the_content', 'wpautop' );
  remove_filter( 'the_excerpt', 'wpautop' );

This also didn't resolve the issue.

The line breaks works perfectly if p tags have no direction attribute while when it has the dir attribute like this <p dir="ltr">&nbsp;</p> they are removed.

Any line break after it gets stripped off especially if it's a non-latin language.

发布评论

评论列表(0)

  1. 暂无评论