Skip to:
Content

bbPress.org

Ticket #3352: bbp-3352.patch

File bbp-3352.patch, 1.1 KB (added by codejp3, 9 months ago)

patch for ticket 3352 to allow custom bbpress number of links within content, and prevent local site links from being counted against the max links value

  • src/includes/common/functions.php

     
    901901
    902902        // Only check max_links when not being strict
    903903        if ( false === $strict ) {
    904                 $max_links = get_option( 'comment_max_links' );
     904                // Get max number of links from WP core, with optional filter override
     905                // https://bbpress.trac.wordpress.org/ticket/3352
     906                $max_links = apply_filters( 'bbp_comment_max_links', get_option( 'comment_max_links' ) );
    905907                if ( ! empty( $max_links ) ) {
    906908
    907909                        // How many links?
    908910                        $num_links = preg_match_all( '/(http|ftp|https):\/\//i', $content, $match_out );
     911                       
     912                        // Neutralize the current site's URL.
     913                        // https://bbpress.trac.wordpress.org/ticket/3352
     914                        if ( isset( $match_out[0] ) && is_array( $match_out[0] ) ) {
     915                                foreach ( $match_out[0] as $found_url ) {
     916                                        if ( 0 === strpos( $found_url, home_url() ) ) {
     917                                                $num_links -=1;
     918                                        }
     919                                }
     920                        }
    909921
    910922                        // Allow for bumping the max to include the user's URL
    911923                        if ( ! empty( $_post['url'] ) ) {