improved structured data - PHP<=5.4 compatibility fix plus few little tweaks
This commit is contained in:
parent
2189cc17e2
commit
f5187d650a
|
@ -302,21 +302,28 @@ class WC_Structured_Data {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $breadcrumb = $breadcrumb['breadcrumb'] ) ) {
|
if ( isset( $breadcrumb['breadcrumb'] ) ) {
|
||||||
|
$breadcrumb = $breadcrumb['breadcrumb'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $breadcrumb ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$position = 1;
|
$position = 1;
|
||||||
|
|
||||||
foreach ( $breadcrumb as $key => $value ) {
|
foreach ( $breadcrumb as $key => $crumb ) {
|
||||||
$markup_crumbs[] = array(
|
$markup_crumbs[ $key ] = array(
|
||||||
'@type' => 'ListItem',
|
'@type' => 'ListItem',
|
||||||
'position' => $position ++,
|
'position' => $position ++,
|
||||||
'item' => array(
|
'item' => array(
|
||||||
'@id' => ! empty( $value[1] ) && sizeof( $breadcrumb ) !== $key + 1 ? $value[1] : '#',
|
'name' => $crumb[0],
|
||||||
'name' => $value[0],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
|
||||||
|
$markup_crumbs[ $key ]['item'] += array( '@id' => $crumb[1] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$markup['@type'] = 'BreadcrumbList';
|
$markup['@type'] = 'BreadcrumbList';
|
||||||
|
|
Loading…
Reference in New Issue