Support » Plugin: Social Sharing Plugin - Social Warfare » Clean Out Pin Buttons wraps content in DOCTYPE/HTML wrapper

  • Resolved amatheson

    (@amatheson)


    TL;DR – your clean_out_pin_buttons() function in lib/utilities/SWP_Compatibility.php needs to be updated so it doesn’t wrap ‘the_content’ in DOCTYPE and HTML tags. Change your call to loadHTML() so that it uses the LIBXML_HTML_NOIMPLIED and LIBXML_HTML_NODEFDTD options.

    I was troubleshooting various issues with a site today where the DIVI mobile menu wouldn’t work on Chrome (did work on FireFox) and it appeared like some scripts and styles were being duplicated. The site is using WP Rocket and when I disabled WP Rocket the issues went away. First I thought it was a javascript combining/minification issue and spent hours looking at that side of it. Nothing seemed to fix the problem, except if I disabled Social Warfare.

    So that got me looking at the interaction between Social Warfare and WP Rocket. When WP Rocket is enabled, it combines/minifies the javascript and appends it to the content just before the closing ‘</body>’ tag. When I looked at the page HTML, I found that WP Rocket was including the combined/minified script TWICE in the file. Looking closer, I noticed a stray ‘</body></html>’ in the middle of the content. Tracing that backup I noticed the content was wrapped in:

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html><body>
    ...
    </body></html>
    

    Digging through the code further, I discovered that in May 2019 you added a function, clean_out_pin_buttons() that parses the content using the PHP DOMDocument. You do your parsing and then you call saveHTML() which saves the content as a valid HTML document, including the full DOCTYPE and HTML/Body wrappers.

    This of course leads to invalid HTML and screws up the minification process for WP Rocket. Please look at the documentation for loadHTML() and make use of the LIBXML_HTML_NOIMPLIED and LIBXML_HTML_NODEFDTD options. This should avoid the output being wrapped in these extra tags.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Clean Out Pin Buttons wraps content in DOCTYPE/HTML wrapper’ is closed to new replies.