Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


WordPress Request Buster

Stanislav KhromovStanislav Khromov

WordPress has functions for getting remote resources (using cURL or PHP streams). When these functions run during a page load request, they will slow down your site, because WordPress has to wait for the external request before returning the page. This is bad practice, yet so many plugins and themes use it. Debugging is notoriously hard because requests appear only occasionally (they are often cached via the Transients API).

Request Buster is a plugin that shows you in the top admin bar if any remote requests were triggered by the current page load. Keeping it open as you develop and use your site will let you find plugins that make remote requests.

The plugin is available on GitHub – click here.

The correct way

The correct way to handle loading of remote resources are:

Here are the functions this plugin catches:

wp_remote_get
wp_remote_head
wp_remote_post
wp_remote_request
wp_safe_remote_get
wp_safe_remote_head
wp_safe_remote_post
wp_safe_remote_request

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 0
There are currently no comments.