links->broken_raw_urls_in_post( $post_id ); if ( empty( $broken ) ) { return $content; } $broken = array_flip( $broken ); $mark = LinkTender_Settings::get( 'mark_broken' ); $nofollow = LinkTender_Settings::get( 'nofollow_broken' ); $processor = new WP_HTML_Tag_Processor( $content ); while ( $processor->next_tag( 'a' ) ) { $href = $processor->get_attribute( 'href' ); if ( ! is_string( $href ) || ! isset( $broken[ $href ] ) ) { continue; } if ( $mark ) { $processor->add_class( 'linktender-broken' ); } if ( $nofollow ) { $rel = (string) $processor->get_attribute( 'rel' ); if ( false === strpos( $rel, 'nofollow' ) ) { $processor->set_attribute( 'rel', trim( $rel . ' nofollow' ) ); } } } return $processor->get_updated_html(); } }