WordPress.org

Make WordPress Core

Opened 12 days ago

Closed 38 hours ago

#40993 closed defect (bug) (invalid)

WordPress is auto-generating a line break in my widgets

Reported by: sandduner350 Owned by:
Milestone: Priority: normal
Severity: major Version: 4.8
Component: Widgets Keywords: 2nd-opinion
Focuses: Cc:

Description (last modified by westonruter)

[]I upgraded to WordPress 4.8.I have a text widget that I was using html code with a div inside the div was my social media sprites. With the following code:

<div id="socialmedia">

<a class="youtube" href="https://www.youtube.com/channel/UC2ZdXxa9tiTmuy1_eIQ47iA" target="_blank" rel="nofollow"> </a>
<a class="twitter" href="https://twitter.com/KaoticMoto" target="_blank" rel="nofollow"> </a>
<a class="google" href="https://plus.google.com/b/110788621461808163295" target="_blank" rel="nofollow"> </a>
<a class="facebook" href="https://www.facebook.com/KaoticMoto/" target="_blank" rel="nofollow"> </a>
<a class="instagram" href"https:="" www.instagram.com="" kaoticmoto="" "="" target="_blank" rel="nofollow"> </a>


</div>

They are supposed to be showing up in a row but when you go to the website it shows a list.

When I inspect the element with chrome and firefox it shows a <br>

This is the code from the Chrome inspector (inserting the <br>)
<div id="socialmedia">

<a class="youtube" href="https://www.youtube.com/channel/UC2ZdXxa9tiTmuy1_eIQ47iA" target="_blank" rel="nofollow"> </a><br>
<a class="twitter" href="https://twitter.com/KaoticMoto" target="_blank" rel="nofollow"> </a><br>
<a class="google" href="https://plus.google.com/b/110788621461808163295" target="_blank" rel="nofollow"> </a><br>
<a class="facebook" href="https://www.facebook.com/KaoticMoto/" target="_blank" rel="nofollow"> </a><br>
<a class="instagram" href"https:="" www.instagram.com="" kaoticmoto="" "="" target="_blank" rel="nofollow"> </a><p></p></div>

When I go back in to edit the code for that widget the only thing it shows is:

<div id="socialmedia">

</div>

I can't find any information on how to fix this online.

Change History (4)

#1 @afercia
12 days ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

@sandduner350 welcome. This issue has been previously reported in #40951. Please do feel free to follow the progress on that ticket.

#2 @bobbingwide
2 days ago

  • Keywords 2nd-opinion added
  • Resolution duplicate deleted
  • Severity changed from normal to major
  • Status changed from closed to reopened
  • Summary changed from Wordpress is auto-generating a line break in my widgets to WordPress is auto-generating a line break in my widgets

In my opinion this is a separate issue from #40951.

It is associated with running wpautop() against the content to generate breaks.

In my scenario the text widget contains a simple shortcode:

[add_to_cart id=101]

Once the shortcode has been expanded the HTML gets mangled by wpautop and the resulting output is incorrectly styled.

Using the add-paragraphs-option-to-text-widget plugin, which re-introduces the capability of setting the filter field to false, gives the desired results.

#3 follow-up: @westonruter
38 hours ago

  • Description modified (diff)

@bobbingwide shortcodes are not supported in Text widgets, so you must be adding support via a plugin? The filter priorities probably need to be modified so that shortcodes are processed earlier than wpautop.

Rationale for shortcodes not being supported in core is explained in https://make.wordpress.org/core/2017/05/23/addition-of-tinymce-to-the-text-widget/

#4 in reply to: ↑ 3 @sandduner350
38 hours ago

  • Resolution set to invalid
  • Status changed from reopened to closed

My code that I use is not shortcodes. It is straight HTML for links to my social media sprites. and links to my social media accounts. When I saved it the widget put the line breaks in the code, so the links showed up in a list.

When I save it and go back it doesn't show the code, it just shows the empty div I created for the formatting.

Note: See TracTickets for help on using tickets.