I have a plugin that detects the useragent of a request made during the init hook and if it matches my desired value, I set a flag so that my own xml content is sent during the found_posts filter instead of the html that the theme sends.

the problem is that on a few rare sites, the theme is sending some of it's content before my plugin can send it's own which causes the the external site that is calling to have an xml error because there is non xml code before the bit my plugin sends.

I've tried installing the theme to my local server but the problem doesn't happen there, everything is ticketyboo! so I can only imagine that it is something to do with the server that the site is hosted on. It only seems to happen when someone has set their theme to use a custom homepage.

What could be causing this?

I can show what happens if I use the useragent switcher plugin for firefox and set it to use a new useragent of "Commentluv" and visit http://willtaft.com which shows the xml error . viewing the source of the page shows that my plugin didn't send it's content until most of the theme content had already been output

if I view http://willtaft.com/blog/ using the firefox set to send the 'Commentluv' useragent then everything is working as it should and I can see the xml my plugin sends.

This is driving me crazy! I can't replicate the problem on any of my sites, it only happens on a very few sites and then, only with sites using a custom home page.

I've even tried using an output buffer at the init stage if it detects that the Commentluv useragent is requesting the page and clearing it before my plugin sends the xml but even that wont work on the problem sites.

I'd love to hear any suggestions

  • Any progress? Was my answer useful? Is there something missing? – fuxia Oct 6 '12 at 22:27

Hook into 'plugins_loaded', that should be early enough. Theme output cannot be sent at this stage, so you should be safe – if you really just need the user agent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.