Making WordPress.org


Ignore:
Timestamp:
04/07/2020 10:31:44 AM (6 years ago)
Author:
Otto42
Message:

Support forums: Add ugc to links in topic and replies content (which already had nofollow). See #4958.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r9663 r9708  
    4848                remove_filter( 'bbp_get_topic_author_link', 'bbp_rel_nofollow' );
    4949                remove_filter( 'bbp_get_reply_author_link', 'bbp_rel_nofollow' );
     50
     51                // add ugc to links in topics and replies. These already have nofollow, this adds ugc as well
     52                add_filter( 'bbp_get_reply_content', array( $this, 'add_rel_ugc' ), 80 );
     53                add_filter( 'bbp_get_topic_content', array( $this, 'add_rel_ugc' ), 80 );
    5054
    5155                // oEmbed.
     
    752756
    753757        /**
     758         * Add nofollow ugc to links in content, for post-save processing. Compare to wp_rel_ugc().
     759         */
     760        public function add_rel_ugc( $text ) {
     761                $text = preg_replace_callback(
     762                        '|<a (.+?)>|i',
     763                        function( $matches ) {
     764                                return wp_rel_callback( $matches, 'nofollow ugc' );
     765                        },
     766                        $text
     767                );
     768                return $text;
     769        }
     770
     771        /**
    754772         * Adjust the login URL to point back to whatever part of the support forums we're
    755773         * currently looking at. This allows the redirect to come back to the same place
Note: See TracChangeset for help on using the changeset viewer.