I was recently working on a WooCommerce store that had a very slow wp-admin. There were likely several factors involved, Query Monitor made it easy to see several API calls being made with every page load.

If I could get rid of those API calls, then I could significantly increase the performance of wp-admin. With the WooCommerce Square plugin having the slowest API call, I started there.
After investigating, I found out that the API call was there to check if the server supported loopback connections. Since I knew my server did support loopback connections, I didn’t need this check. So, I just mocked out the API call, effectively removing it. Here’s the code that I used for that:
add_filter( 'pre_http_request', 'sport_shooting_depot_mock_square_background_check', 10, 3 );
function sport_shooting_depot_mock_square_background_check( $preemt, $args, $url ) {
if ( $url !== 'YOUR_SITE_URL_HERE/wp-admin/admin-ajax.php?action=wc_square_background_sync_test' ) {
return false;
}
return array(
'body' => '[TEST_LOOPBACK]',
'response' => array(
'code' => '200 OK'
),
);
}
Leave a Reply