@@ -162,20 +162,35 @@ public static function generate_commentdata( $commentdata ) {
162162
163163 // if author is present use the informations for the comment
164164 if ( $ author ) {
165- if ( isset ( $ properties ['name ' ] ) ) {
166- $ commentdata ['comment_author ' ] = wp_slash ( $ author ['name ' ] );
165+ if ( ! is_array ( $ author ) ) {
166+ if ( self ::is_url ( $ author ) ) {
167+ $ response = Linkbacks_Handler::retrieve ( $ author );
168+ if ( ! is_wp_error ( $ response ) ) {
169+ $ parser = new Parser ( wp_remote_retrieve_body ( $ response ), $ author );
170+ $ author_array = $ parser ->parse ( true );
171+ $ properties ['author ' ] = $ author = self ::get_representative_author ( $ author_array , $ author );
172+ }
173+ } else {
174+ $ comment_data ['comment_author ' ] = wp_slash ( $ author );
175+ }
167176 }
168177
169- if ( isset ( $ author ['email ' ] ) ) {
170- $ commentdata ['comment_author_email ' ] = wp_slash ( $ author ['email ' ] );
171- }
178+ if ( is_array ( $ author ) ) {
179+ if ( isset ( $ properties ['name ' ] ) ) {
180+ $ commentdata ['comment_author ' ] = wp_slash ( $ author ['name ' ] );
181+ }
172182
173- if ( isset ( $ author ['url ' ] ) ) {
174- $ commentdata ['comment_meta ' ][ ' semantic_linkbacks_author_url ' ] = $ author ['url ' ] ;
175- }
183+ if ( isset ( $ author ['email ' ] ) ) {
184+ $ commentdata ['comment_author_email ' ] = wp_slash ( $ author ['email ' ] ) ;
185+ }
176186
177- if ( isset ( $ properties ['photo ' ] ) ) {
178- $ commentdata ['comment_meta ' ]['semantic_linkbacks_avatar ' ] = $ author ['photo ' ];
187+ if ( isset ( $ author ['url ' ] ) ) {
188+ $ commentdata ['comment_meta ' ]['semantic_linkbacks_author_url ' ] = $ author ['url ' ];
189+ }
190+
191+ if ( isset ( $ properties ['photo ' ] ) ) {
192+ $ commentdata ['comment_meta ' ]['semantic_linkbacks_avatar ' ] = $ author ['photo ' ];
193+ }
179194 }
180195 }
181196
@@ -380,8 +395,8 @@ public static function get_representative_author( $mf_array, $source ) {
380395 // check domain
381396 if ( isset ( $ mf ['properties ' ] ) && isset ( $ mf ['properties ' ]['url ' ] ) ) {
382397 foreach ( $ mf ['properties ' ]['url ' ] as $ url ) {
383- if ( parse_url ( $ url , PHP_URL_HOST ) == parse_url ( $ source , PHP_URL_HOST ) ) {
384- return $ mf[ ' properties ' ] ;
398+ if ( wp_parse_url ( $ url , PHP_URL_HOST ) == wp_parse_url ( $ source , PHP_URL_HOST ) ) {
399+ return self :: flatten_microformats ( $ mf ) ;
385400 break ;
386401 }
387402 }
0 commit comments