• Resolved KZeni

    (@kzeni)


    I noticed the Google-powered Site Search (https://www.google.com/cse/) my site uses wasn’t being shown. I looked at the page’s source, and it appears the <gcse:search> and </gcse:search> required by Google was being turned into <search> and </search> server-side… thus breaking the site’s Google-powered search.

    Some poking around showed that this was entirely caused by the HTML srcset option of this plugin. Turns out this option uses DOMDocument’s saveHTML() function (rather than HTML rewrite returning a str_replace modified $buffer), and it’s likely the cause of the required “gcse:” part of the Google search tags being stripped from the page.

    I’m looking for a fix to this, but I’m guessing it might mean this part of the plugin uses something like https://simplehtmldom.sourceforge.net to accomplish this (hopefully this doesn’t share the same issue), or uses the same method as the HTML rewrite option.

    Thanks in advance for anything you find & hoping for a fix!

    https://www.ads-software.com/plugins/wp-retina-2x/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter KZeni

    (@kzeni)

    Ok, I was able to rewrite the wr2x_srcset_rewrite function to address this issue. Here’s a link to the code that’s the updated function (really, just swapped out some code once a potential retina is found & then changed it to return the modified buffer… but it’s simpler to just show the updated function as a whole).

    https://gist.github.com/KZeni/7205026

    This now works after I swapped out this function with the code found in the link above.

    Now, I’m not sure of the reasoning behind why things were coded as they were so you might find that there’s a better way to do this, but as it is… this fixes an issue where this was otherwise breaking my site’s Google-powered search.

    I’d like to see this (or an equivalent fix) included in a future update to this plugin. I love this plugin, but I need Google search to work. Thanks!

    Thread Starter KZeni

    (@kzeni)

    UPDATE. I want to point out that the old way the wr2x_srcset_rewrite function was set up was creating a second problem. I have a site using HTML5 tags (<header>, <footer>, etc.), and using the srcset rewrite method had the plugin adding a second set of doctype (loose html4) & opening html/head tags within wp_head and closing body/html tags within wp_footer.

    This seems like an important fix as it was butchering the site’s markup, and it’s no good having the most forward-looking method use a DOM parser that breaks when given HTML5 tags. My suggested fix for allowing Google Site Search to work (above) also makes it so sites using HTML5 markup work as well.

    Here’s a link the fix again: https://gist.github.com/KZeni/7205026 (just swap out that whole function found in wp-retina-2x.php)

    Plugin Author Jordy Meow

    (@tigroumeow)

    Sorry for coming back to you so late on this. That’s a great fix, I’m glad you found this by yourself and proposed a fix.

    I will update the plugin ASAP after some more testing.

    Thread Starter KZeni

    (@kzeni)

    I appreciate you looking into it for the next release!

    Plugin Author Jordy Meow

    (@tigroumeow)

    In 2-3 hours ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘HTML srcset option breaks Google Site Search’ is closed to new replies.