@@ -427,12 +427,20 @@ public function find_representative_item( $mf_array, $target ) {
427
427
}
428
428
// Make sure this is a numeric array before checking this.
429
429
if ( wp_is_numeric_array ( $ obj_values ) ) {
430
+ $ obj_value = current ( $ obj_values );
430
431
// check content for the link
431
- if ( 'content ' === $ obj_key &&
432
- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_values [0 ]['html ' ], $ context ) ) {
432
+ if (
433
+ 'content ' === $ obj_key &&
434
+ ! empty ( $ obj_value ['html ' ] ) &&
435
+ is_string ( $ obj_value ['html ' ] ) &&
436
+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_value ['html ' ], $ context )
437
+ ) {
433
438
return $ item ;
434
- } elseif ( 'summary ' === $ obj_key &&
435
- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_values [0 ], $ context ) ) {
439
+ } elseif (
440
+ 'summary ' === $ obj_key &&
441
+ is_string ( $ obj_value ) &&
442
+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_value , $ context )
443
+ ) {
436
444
return $ item ;
437
445
}
438
446
}
@@ -444,13 +452,23 @@ public function find_representative_item( $mf_array, $target ) {
444
452
445
453
// check properties if target urls was mentioned
446
454
foreach ( $ item ['properties ' ] as $ key => $ values ) {
447
- // check content for the link
448
- if ( 'content ' === $ key &&
449
- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ values [0 ]['html ' ], $ context ) ) {
450
- return $ item ;
451
- } elseif ( 'summary ' === $ key &&
452
- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ values [0 ], $ context ) ) {
453
- return $ item ;
455
+ if ( wp_is_numeric_array ( $ values ) ) {
456
+ $ value = current ( $ values );
457
+ // check content for the link
458
+ if (
459
+ 'content ' === $ key &&
460
+ ! empty ( $ value ['html ' ] ) &&
461
+ is_string ( $ value ['html ' ] ) &&
462
+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ value ['html ' ], $ context )
463
+ ) {
464
+ return $ item ;
465
+ } elseif (
466
+ 'summary ' === $ key &&
467
+ is_string ( $ value ) &&
468
+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ value , $ context )
469
+ ) {
470
+ return $ item ;
471
+ }
454
472
}
455
473
}
456
474
}
0 commit comments