Commit 9f1907d8 by Scott

Fix errors in structured data

parent ef53ed4c
......@@ -572,8 +572,12 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
$fields['what'] = qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented'));
if (@$options['whatlink'] && strlen(@$options['q_request'])) {
$fields['what_url'] = ($post['basetype'] == 'Q') ? qa_path_html($options['q_request'])
$fields['what_url'] = $post['basetype'] == 'Q'
? qa_path_html($options['q_request'])
: qa_path_html($options['q_request'], array('show' => $postid), null, null, qa_anchor($post['basetype'], $postid));
if ($microdata) {
$fields['what_url_tags'] = ' itemprop="url"';
}
}
}
......@@ -737,7 +741,7 @@ function qa_message_html_fields($message, $options = array())
* @param int $postuserid The post user's ID.
* @param array $usershtml Array of HTML representing usernames.
* @param string $ip The post user's IP.
* @param bool|string $microdata Whether to include microdata (no longer used).
* @param bool|string $microdata Whether to include microdata.
* @param string $name The author's username.
* @return array The HTML.
*/
......
......@@ -592,7 +592,6 @@ function qa_post_html_defaults($basetype, $full = false)
'blockwordspreg' => qa_get_block_words_preg(),
'showurllinks' => qa_opt('show_url_links'),
'linksnewwindow' => qa_opt('links_in_new_window'),
'microformats' => $full,
'fulldatedays' => qa_opt('show_full_date_days'),
);
}
......
......@@ -260,7 +260,7 @@ $microdata = qa_opt('use_microdata');
if ($microdata) {
$qa_content['head_lines'][] = '<meta itemprop="name" content="' . qa_html($qa_content['q_view']['raw']['title']) . '">';
$qa_content['html_tags'] .= ' itemscope itemtype="http://schema.org/QAPage"';
$qa_content['main_tags'] = ' itemscope itemtype="http://schema.org/Question"';
$qa_content['main_tags'] = ' itemprop="mainEntity" itemscope itemtype="http://schema.org/Question"';
}
......
......@@ -1955,13 +1955,16 @@ class qa_html_theme_base
{
if (isset($post['what'])) {
$classes = $class . '-what';
if (@$post['what_your'])
if (isset($post['what_your']) && $post['what_your']) {
$classes .= ' ' . $class . '-what-your';
}
if (isset($post['what_url']))
$this->output('<a href="' . $post['what_url'] . '" class="' . $classes . '">' . $post['what'] . '</a>');
else
if (isset($post['what_url'])) {
$tags = isset($post['what_url_tags']) ? $post['what_url_tags'] : '';
$this->output('<a href="' . $post['what_url'] . '" class="' . $classes . '"' . $tags . '>' . $post['what'] . '</a>');
} else {
$this->output('<span class="' . $classes . '">' . $post['what'] . '</span>');
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment