I'm wondering if anyone can help me with how to disable all third party calls to Gravatar.com within wordpress.
The Problem:
I run a few sites that use WordPress as a CMS and not really as a blogging platform. These sites are ecommerce and shopping related and thus don't really use or require comments or gravatar support. I'm not interested in using avatars or gravatars for post authors etc so I'm not concerned if I need to disable all avatar functionality.
I've disabled Gravatars/Avatars withing settings>discussion but that only stops gravatars and avatars from being displayed. Upon each page load a call/query to "Gravatar.com" is still made, even though I'm not using the feature. I'd like to STOP the calls to Gravatar.com since I'm painstakingly optimizing the sites for speed and this is a small but still unnecessary request made.
ATTEMPTED SOLUTIONS:
Ideally I'd like to do this through functions.php within a child theme or something similar. I try to keep plugin use to a bare minimum as well. Gravatar support is within Wordpress core and obviously I don't want to edit any core files. I'm looking for a simple coding solution but admittedly I'm not the greatest with hooks, filters and php.
1. As stated, disabling gravatars within WordPress "Discussion" settings doesn't work to stop the requests to Gravatar.com. It only prevents them from displaying on the site. The site still calls Gravatar.com upon loading.
2. I've attempted adding the following different solutions I've found in my search. I've added these within functions.php at different times and none have worked:
add_filter( 'get_avatar', 'so_disable_gravatars', 10, 2 );
function so_disable_gravatars( $avatar ) {
$avatar = '';
return $avatar;
}
and
add_filter('get_avatar', 'get_no_gravatar', 1, 2);
function get_no_gravatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
// put your new function in here
$avatar = "<img alt='image_alt' src='#' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
};
I've searched the forums and Google extensively and I'm not finding anything that works. Most posts are from 2-4 years ago or older.
I don't want to use a plugin for this but when I did do a plug in search it mainly returned old plugins that haven't been supported or updated in over 2 years.
I realize this isn't having a huge performance impact but it's a journey I've set out on and there's no looking back. At this point this has become a battle I have to win as a matter of principle. ;)
Can anyone help with a solution on how to easily disable calls to Gravatar.com when you're not using Gravatars at all?