+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'];
+ }
+
+ // check included h-* formats and their links
+ foreach ($values as $obj) {
+ if(isset($obj['type']) && array_intersect(array('h-cite', 'h-entry'), $obj['type']) &&
+ isset($obj['properties']) && isset($obj['properties']['url']) &&
+ count(array_filter($obj['properties']['url'],
+ function($x) use ($target) { return linkback_lenient_target_match($x, $target); })) > 0
+ ) {
+ return $entry['properties'];
+ }
+ }
+
+ // check content for the link
+ if ($key == "content" && preg_match_all("/<a[^>]+?".preg_quote($target, "/")."[^>]*>([^>]+?)<\/a>/i", htmlspecialchars_decode($values[0]['html']), $context)) {
+ return $entry['properties'];
+ // check summary for the link
+ } elseif ($key == "summary" && preg_match_all("/<a[^>]+?".preg_quote($target, "/")."[^>]*>([^>]+?)<\/a>/i", htmlspecialchars_decode($values[0]), $context)) {
+ return $entry['properties'];
+ }
+ }
+
+ foreach((array)$entry['children'] as $mf2) {
+ if(linkback_is_contained_in($mf2, $target)) {
+ return $entry['properties'];
+ }
+ }
+
+ return null;
+}
+