#40993 closed defect (bug) (invalid)
WordPress is auto-generating a line break in my widgets
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 4.8 |
Component: | Widgets | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description (last modified by )
[]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 (8)
#1
@
8 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
#2
@
8 years 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-ups:
↓ 4
↓ 5
↓ 6
@
8 years 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
@
8 years 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.
#5
in reply to:
↑ 3
@
8 years ago
Replying to westonruter:
@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
.
Yes, my plugin has supported shortcodes in widgets for a very long time. Using the checkbox to control automatic paragraph creation worked fine. Then the checkbox was removed and it broke my code.
#6
in reply to:
↑ 3
@
8 years ago
Replying to westonruter:
The filter priorities probably need to be modified so that shortcodes are processed earlier than
wpautop
.
It's the other way round. Shortcodes need to be processed after wpautop.
This is a bit of a challenge for two reasons
widget_text
is invoked beforewidget_text_content
- We can't guarantee that
widget_text_content
gets invoked.
Therefore I can't simply change the original code
add_filter('widget_text', 'do_shortcode' );
to
add_filter('widget_text_content', 'do_shortcode', 20 );
So I need to implement a different solution to disable the widget_text_content
filter functions when shortcodes have been detected in the widget content.
PS. There's a typo in the 23 May post; line beaks.
#7
follow-up:
↓ 8
@
8 years ago
@bobbingwide You should see that all of this has been accounted for in #40951.
This has been committed to trunk
so please test to confirm.
#8
in reply to:
↑ 7
@
8 years ago
Replying to westonruter:
This has been committed to
trunk
so please test to confirm.
I've tested a couple of my text widgets which contain shortcodes and found the just-in-time solution to be OK. But I have a couple of problems with the Custom HTML widget. I'll add some comments to #40951.
@sandduner350 welcome. This issue has been previously reported in #40951. Please do feel free to follow the progress on that ticket.