WordPress.org

Make WordPress Core

Ticket #14681: 14681.patch

File 14681.patch, 793 bytes (added by hakre, 4 years ago)

Adding a filter to enable plugin authors to override the current way of counting all comment links, so to be able to provide a count of external links only.

  • wp-includes/comment.php

     
    4747 
    4848        // Check # of external links 
    4949        if ( $max_links = get_option( 'comment_max_links' ) ) { 
    50                 $num_links = preg_match_all( '/<a [^>]*href/i', apply_filters( 'comment_text', $comment ), $out ); 
     50                $comment   = apply_filters( 'comment_text', $comment ); 
     51                $num_links = preg_match_all( '/<a [^>]*href/i', $comment , $out ); 
     52                $num_links = apply_filters( 'comment_max_links_comment', $num_links, $comment, $out ); 
    5153                $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); // provide for counting of $url as a link 
    5254                if ( $num_links >= $max_links ) 
    5355                        return false;