Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit c9b32bd

Browse files
committed
Merge in rel-me if available to add data to the author property and extract rel-author if no other option
1 parent 8cd9a9a commit c9b32bd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

includes/class-linkbacks-mf2-handler.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ public static function generate_commentdata( $commentdata ) {
176176
}
177177

178178
if ( is_array( $author ) ) {
179+
if ( ! isset( $author['me'] ) ) {
180+
if ( isset( $mf_array['rels']['me'] ) ) {
181+
$properties['author']['me'] = $author['me'] = $mf_array['rels']['me'];
182+
}
183+
}
179184
if ( isset( $properties['name'] ) ) {
180185
$commentdata['comment_author'] = wp_slash( $author['name'] );
181186
}
@@ -396,7 +401,11 @@ public static function get_representative_author( $mf_array, $source ) {
396401
if ( isset( $mf['properties'] ) && isset( $mf['properties']['url'] ) ) {
397402
foreach ( $mf['properties']['url'] as $url ) {
398403
if ( wp_parse_url( $url, PHP_URL_HOST ) == wp_parse_url( $source, PHP_URL_HOST ) ) {
399-
return self::flatten_microformats( $mf );
404+
$flat = self::flatten_microformats( $mf );
405+
if ( isset( $mf_array['rels']['me'] ) ) {
406+
$flat['me'] = $mf_array['rels']['me'];
407+
}
408+
return $flat;
400409
break;
401410
}
402411
}
@@ -405,6 +414,11 @@ public static function get_representative_author( $mf_array, $source ) {
405414
}
406415
}
407416

417+
// If there is no h-card then return rel=author and see what can be done with it
418+
if ( isset( $mf_array['rels']['author'] ) ) {
419+
return $mf_array['rels']['author'];
420+
}
421+
408422
return null;
409423
}
410424

0 commit comments

Comments
 (0)