@@ -46,9 +46,7 @@ public static function init() {
4646 add_action ('pingback_post ' , array ('SemanticLinkbacksPlugin ' , 'linkback_fix ' ));
4747 add_action ('trackback_post ' , array ('SemanticLinkbacksPlugin ' , 'linkback_fix ' ));
4848 add_action ('webmention_post ' , array ('SemanticLinkbacksPlugin ' , 'linkback_fix ' ));
49-
50- add_filter ('get_avatar ' , array ('SemanticLinkbacksPlugin ' , 'get_avatar ' ), 11 , 5 );
51-
49+ add_filter ('pre_get_avatar_data ' , array ('SemanticLinkbacksPlugin ' , 'pre_get_avatar_data ' ), 11 , 5 );
5250 // To extend or to override the default behavior, just use the `comment_text` filter with a lower
5351 // priority (so that it's called after this one) or remove the filters completely in
5452 // your code: `remove_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_add_cite'), 11);`
@@ -337,35 +335,29 @@ public static function comment_text_excerpt($text, $comment = null, $args = arra
337335 /**
338336 * replaces the default avatar with the WebMention uf2 photo
339337 *
340- * @param string $avatar the avatar-url
338+ * @param array $args Arguments passed to get_avatar_data(), after processing.
341339 * @param int|string|object $id_or_email A user ID, email address, or comment object
342- * @param int $size Size of the avatar image
343- * @param string $default URL to a default image to use if no avatar is available
344- * @param string $alt Alternative text to use in image tag. Defaults to blank
345- * @return string new avatar-url
340+ * @return array $args
346341 */
347- public static function get_avatar ($ avatar , $ id_or_email , $ size , $ default = '' , $ alt = '' ) {
342+ public static function pre_get_avatar_data ($ args , $ id_or_email ) {
343+ if (!isset ($ args ['class ' ]) ) {
344+ $ args ['class ' ]=array ('u-photo ' );
345+ }
346+ else {
347+ $ args ['class ' ][]='u-photo ' ;
348+ }
348349 if (!is_object ($ id_or_email ) ||
349350 !isset ($ id_or_email ->comment_type ) ||
350351 !get_comment_meta ($ id_or_email ->comment_ID , 'semantic_linkbacks_avatar ' , true )) {
351- return $ avatar ;
352+ return $ args ;
352353 }
353-
354354 // check if comment has an avatar
355355 $ sl_avatar = get_comment_meta ($ id_or_email ->comment_ID , 'semantic_linkbacks_avatar ' , true );
356-
357- if (! $ sl_avatar) {
358- return $ avatar ;
356+ if ( $ sl_avatar ) {
357+ $ args [ ' url ' ]= $ sl_avatar;
358+ $ args [ ' class ' ][]= ' avatar-semantic-linkbacks ' ;
359359 }
360-
361- if (false === $ alt ) {
362- $ safe_alt = '' ;
363- } else {
364- $ safe_alt = esc_attr ($ alt );
365- }
366-
367- $ avatar = "<img alt=' {$ safe_alt }' src=' {$ sl_avatar }' class='avatar avatar- {$ size } photo u-photo avatar-semantic-linkbacks' height=' {$ size }' width=' {$ size }' /> " ;
368- return $ avatar ;
360+ return $ args ;
369361 }
370362
371363 /**
0 commit comments