Merhabalar,

Wordpress AMPforWP eklentisini kullananlar zaten biliyordur. Masaüstü sitesinde functions.php 'ye atılan kod sayesinde yorum gönderen ziyaretçilerin avatarlarını istediğimiz gibi seçebiliyoruz fakat AMP sitemizde bunlar görünmüyor.

Eklenti yazarına bu konu ile ilgili İngilizce bir mail gönderdim.
Functions.php 'ye eklediğim bir kodu, AMP sayfasına da uygulamak istediğimi söyledim. Kod, belirlediğiniz resimleri random olarak yorum yapan ziyaretçilerin resimleri yapıyor.

Eklenti yazarı yanıt olarak bir kod verdi:
add_filter('ampforwp_get_comments_gravatar', 'new_filter');
function new_filter($url){
$avatarlar = array(
'https://www.kriptobyte.com/wp-content/uploads/2018/03/comment-logo-1.png',
'https://www.kriptobyte.com/wp-content/uploads/2018/03/comment-logo-2.png',
);
$new_url = array_rand($avatarlar);
return $new_url;
}



ve bu kodu eklemem gereken yeri de (features.php) bu şekilde gösterdi ama bu alttaki kodun neresine eklemem gerekiyor onu anlayamadım..

// 91. Comment Author Gravatar URL
if( ! function_exists('ampforwp_get_comments_gravatar') ){
function ampforwp_get_comments_gravatar( $comment ) {
$gravatar_exists = '';
$gravatar_exists = ampforwp_gravatar_checker($comment->comment_author_email);
if($gravatar_exists == true){
return get_avatar_url( $comment, apply_filters( 'ampforwp_get_comments_gravatar', '60' ), '' );
}
else
return;
}
}
// Gravatar Checker
if ( ! function_exists('ampforwp_gravatar_checker') ) {
function ampforwp_gravatar_checker( $email ) {
// Craft a potential url and test its headers
$hash = md5(strtolower(trim($email)));
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
$headers = @get_headers($uri);
// If its 404
if (!preg_match("|200|", $headers[0])) {
$has_valid_avatar = FALSE;
}
// Else if it is 200
else {
$has_valid_avatar = TRUE;
}
return $has_valid_avatar;
}
}


Yardımcı olursanız çok sevinirim..