Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data-vocabulary.org schema deprecated error #14

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions easy_breadcrumb.module
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,24 @@ function easy_breadcrumb_block_view($delta = NULL) {
*/
function template_preprocess_easy_breadcrumb(&$variables) {
$breadcrumbs = _easy_breadcrumb_build_items();
if (module_exists('schemaorg')) {
$variables['list_type'] = 'https://schema.org/BreadcrumbList';
}
else {
$variables['list_type'] = 'http://data-vocabulary.org/Breadcrumb';
}
$variables['list_type'] = 'https://schema.org/BreadcrumbList';
foreach ($breadcrumbs as $i => $breadcrumb) {
if (isset($breadcrumb['url'])) {
$variables['breadcrumb'][$i] = '<span itemprop="title">';
$variables['breadcrumb'][$i] = '<span>';

$parsed_query = '';
$parsed_url = parse_url($breadcrumb['url']);
if (isset($parsed_url['query'])) {
parse_str($parsed_url['query'], $parsed_query);
}
$variables['breadcrumb'][$i] .= l($breadcrumb['content'], $parsed_url['path'], array(
'attributes' => array('class' => $breadcrumb['class']),
$variables['breadcrumb'][$i] .= l('<span itemprop="name">' . $breadcrumb['content'] . '</span>', $parsed_url['path'], array(
'attributes' => array(
'class' => $breadcrumb['class'],
'itemtype' => "http://schema.org/Thing",
'itemprop' => "item",
'itemscope' => "",
'itemid' => check_plain(url($breadcrumb['url'], array('absolute' => TRUE,))),
),
'query' => $parsed_query,
'html' => (!empty($breadcrumb['html'])) ? $breadcrumb['html'] : FALSE,
));
Expand All @@ -148,7 +149,7 @@ function template_preprocess_easy_breadcrumb(&$variables) {
}
else {
$class = implode(' ', $breadcrumb['class']);
$variables['breadcrumb'][$i] = '<span class="' . $class . '" itemprop="title">' . $breadcrumb['content'] . '</span>';
$variables['breadcrumb'][$i] = '<span class="' . $class . '" itemprop="name">' . $breadcrumb['content'] . '</span>';
}
}
$variables['segments_quantity'] = isset($variables['breadcrumb']) ? count($variables['breadcrumb']) : 0;
Expand Down
11 changes: 7 additions & 4 deletions templates/easy-breadcrumb.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
<nav itemscope class="breadcrumb easy-breadcrumb" itemtype="<?php print $list_type; ?>" role="navigation">
<h2 class="element-invisible">You are here</h2>
<?php foreach ($breadcrumb as $i => $item): ?>
<?php print $item; ?>
<?php if (($i + 1) != $segments_quantity || $separator_ending): ?>
<span class="separator"><?php print $separator; ?></span>
<?php endif; ?>
<span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<?php print $item; ?>
<meta itemprop="position" content="<?php print $i; ?>" />
</span>
<?php if (($i + 1) != $segments_quantity || $separator_ending): ?>
<span class="separator"><?php print $separator; ?></span>
<?php endif; ?>
<?php endforeach; ?>
</nav>
<?php endif; ?>