@@ -767,23 +767,38 @@ protected function get_response_type( $entry, $mf_array, $target ) {
767767 // check url
768768 if ( $ this ->has_property ( $ obj , 'url ' ) ) {
769769 // check target
770- if ( $ this ->compare_urls ( $ target , $ obj ['properties ' ]['url ' ] ) ) {
770+ if (
771+ isset ( $ obj ['properties ' ]['url ' ] ) &&
772+ $ this ->compare_urls ( $ target , $ obj ['properties ' ]['url ' ] )
773+ ) {
771774 return $ classes [ $ key ];
772775 }
773776 }
774777
775- // check properties if target urls was mentioned
776- foreach ( $ obj ['properties ' ] as $ obj_key => $ obj_values ) {
777- if ( $ this ->compare_urls ( $ target , $ obj_values ) ) {
778- return $ classes [ $ key ];
779- }
780- // check content for the link
781- if ( 'content ' === $ obj_key &&
782- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_values [0 ]['html ' ], $ context ) ) {
783- return $ classes [ $ key ];
784- } elseif ( 'summary ' === $ obj_key &&
785- preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_values [0 ], $ context ) ) {
786- return $ classes [ $ key ];
778+ if ( isset ( $ obj ['properties ' ] ) && is_array ( $ obj ['properties ' ] ) ) {
779+ // check properties if target urls was mentioned
780+ foreach ( $ obj ['properties ' ] as $ obj_key => $ obj_values ) {
781+ if ( $ this ->compare_urls ( $ target , $ obj_values ) ) {
782+ return $ classes [ $ key ];
783+ }
784+
785+ $ obj_value = current ( $ obj_values );
786+
787+ // check content for the link
788+ if (
789+ 'content ' === $ obj_key &&
790+ ! empty ( $ obj_value ['html ' ] ) &&
791+ is_string ( $ obj_value ['html ' ] ) &&
792+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_value ['html ' ], $ context )
793+ ) {
794+ return $ classes [ $ key ];
795+ } elseif (
796+ 'summary ' === $ obj_key &&
797+ is_string ( $ obj_value ) &&
798+ preg_match_all ( '/<a[^>]+? ' . preg_quote ( $ target , '/ ' ) . '[^>]*>([^>]+?)<\/a>/i ' , $ obj_value , $ context )
799+ ) {
800+ return $ classes [ $ key ];
801+ }
787802 }
788803 }
789804 }
0 commit comments