Search in sub-items for links to the target as well
This commit is contained in:
parent
96e0819f00
commit
aa4d880148
|
@ -61,15 +61,7 @@ function linkback_get_target($target) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Based on https://github.com/acegiak/Semantic-Linkbacks/blob/master/semantic-linkbacks-microformats-handler.php, GPL-2.0+
|
||||
function linkback_find_entry($mf2, $target) {
|
||||
if(isset($mf2['items'][0]['type']) && in_array("h-feed", $mf2['items'][0]["type"]) && isset($mf2['items'][0]['children'])) {
|
||||
$mf2['items'] = $mf2['items'][0]['children'];
|
||||
}
|
||||
|
||||
$entries = array_filter($mf2['items'], function($x) { return isset($x['type']) && in_array('h-entry', $x['type']); });
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
function linkback_is_contained_in($entry, $target) {
|
||||
foreach ((array)$entry['properties'] as $key => $values) {
|
||||
if(count(array_filter($values, function($x) use ($target) { return linkback_lenient_target_match($x, $target); })) > 0) {
|
||||
return $entry['properties'];
|
||||
|
@ -94,6 +86,28 @@ function linkback_find_entry($mf2, $target) {
|
|||
return $entry['properties'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach((array)$entry['children'] as $mf2) {
|
||||
if(linkback_is_contained_in($mf2, $target)) {
|
||||
return $entry['properties'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Based on https://github.com/acegiak/Semantic-Linkbacks/blob/master/semantic-linkbacks-microformats-handler.php, GPL-2.0+
|
||||
function linkback_find_entry($mf2, $target) {
|
||||
if(isset($mf2['items'][0]['type']) && in_array("h-feed", $mf2['items'][0]["type"]) && isset($mf2['items'][0]['children'])) {
|
||||
$mf2['items'] = $mf2['items'][0]['children'];
|
||||
}
|
||||
|
||||
$entries = array_filter($mf2['items'], function($x) { return isset($x['type']) && in_array('h-entry', $x['type']); });
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
if($prop = linkback_is_contained_in($entry, $target)) {
|
||||
return $prop;
|
||||
}
|
||||
}
|
||||
|
||||
// Default to first one
|
||||
|
|
Loading…
Reference in New Issue
Block a user