Skip to content

Commit 5bab348

Browse files
committed
Add microdata for unregistered/anonymous users
1 parent f394a34 commit 5bab348

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

qa-include/app/format.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,11 @@ function qa_who_to_html($isbyuser, $postuserid, $usershtml, $ip = null, $microda
755755
else
756756
$whohtml = qa_lang_html('main/anonymous');
757757

758+
if ($microdata) {
759+
// duplicate HTML from qa_get_one_user_html()
760+
$whohtml = '<span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">' . $whohtml . '</span></span>';
761+
}
762+
758763
if (isset($ip))
759764
$whohtml = qa_ip_anchor_html($ip, $whohtml);
760765
}

qa-include/app/users.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,16 @@ function qa_get_one_user_html($handle, $microdata = false, $favorited = false)
552552

553553
$url = qa_path_html('user/' . $handle);
554554
$favclass = $favorited ? ' qa-user-favorited' : '';
555-
$mfAttr = $microdata ? ' itemprop="name"' : '';
556-
$mfPrefix = $microdata ? '<span itemprop="author" itemscope itemtype="http://schema.org/Person">' : '';
557-
$mfSuffix = $microdata ? '</span>' : '';
555+
$mfAttr = $microdata ? ' itemprop="url"' : '';
558556

559-
return $mfPrefix . '<a href="' . $url . '" class="qa-user-link' . $favclass . '"' . $mfAttr . '>' . qa_html($handle) . '</a>' . $mfSuffix;
557+
$userHandle = $microdata ? '<span itemprop="name">' . qa_html($handle) . '</span>' : qa_html($handle);
558+
$userHtml = '<a href="' . $url . '" class="qa-user-link' . $favclass . '"' . $mfAttr . '>' . $userHandle . '</a>';
559+
560+
if ($microdata) {
561+
$userHtml = '<span itemprop="author" itemscope itemtype="http://schema.org/Person">' . $userHtml . '</span>';
562+
}
563+
564+
return $userHtml;
560565
}
561566

562567

0 commit comments

Comments
 (0)