We use a plugin called Recent Posts Widget Extended (RPWE) to nicely format categorized lists of posts on our company’s support website (WordPress, naturally). It works great, but more importantly, it'd be too much work to take it out at this point.
I recently started implementing a third-party tool that calls the WP API to search for posts based on a (string) search term. The query looks like this: https://example.com/wp-json/wp/v2/posts?search=asdf And the result is supposed to be a nice json array of posts.
However (and this is the strange part)... Somehow, RPWE is getting in the way and outputting a chunk of CSS into the result, right at the top. Since the caller is expecting json only, it breaks our integration. Why the heck would plugin code be called during a call to the REST engine?
I’ve tried playing around in the RPWE plugin code–I see the exact line where it inserts that CSS, and I added some “if” logic to only output the CSS if a certain shortcode attribute were present. The results are strange: if I call the API directly, right after loading a WP page with RPWE on it, it still fails (as if RPWE remembers being loaded from the UI). (I also tried just taking out the line where it inserts the CSS. That fixes the API issues, but then the styling on our site where we actually use the plugins, goes away.)
Am I missing something obvious? I’m not a WP expert (C# and javascript is my trade), so maybe there’s just some setting I need to know about? Mystery #1 is, why the heck is this plugin code being called at all on a pure REST call?
Many thanks!!