Ticket #11359: 11359.diff
File 11359.diff, 9.7 KB (added by , 10 years ago) |
---|
-
wp-includes/comment-template.php
185 185 $url = get_comment_author_url( $comment_ID ); 186 186 $author = get_comment_author( $comment_ID ); 187 187 188 if ( empty( $url ) || 'http://' == $url ) 188 if ( empty( $url ) || 'http://' == $url ) { 189 189 $return = $author; 190 else 191 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; 190 } else { 191 // By default, add rel=nofollow to author links 192 $nofollow = ' nofollow'; 193 $comment = get_comment( $comment_ID ); 194 // If the author can edit comments, no need to rel=unfollow the link 195 if ( $comment->user_id > 0 && user_can( $comment->user_id, 'edit_comment' ) ) { 196 $nofollow = ''; 197 } 198 199 $return = "<a href='$url' rel='external$nofollow' class='url'>$author</a>"; 200 } 192 201 193 202 /** 194 203 * Filter the comment author's link for display. -
wp-includes/comment.php
1726 1726 * 1727 1727 * @param int $comment_content The comment content. 1728 1728 */ 1729 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );1729 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'], isset( $commentdata['user_id'] ) ? $commentdata['user_id'] : null ); 1730 1730 /** 1731 1731 * Filter the comment author's IP before it is set. 1732 1732 * -
wp-includes/default-filters.php
142 142 add_filter( 'the_excerpt', 'shortcode_unautop'); 143 143 add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); 144 144 145 add_filter( 'comment_text', 'wptexturize' );146 add_filter( 'comment_text', 'convert_chars' );147 add_filter( 'comment_text', 'make_c lickable', 9);148 add_filter( 'comment_text', 'force_balance_tags', 25);149 add_filter( 'comment_text', 'convert_smilies', 20);150 add_filter( 'comment_text', 'wpautop', 30);145 add_filter( 'comment_text', 'wptexturize' ); 146 add_filter( 'comment_text', 'convert_chars' ); 147 add_filter( 'comment_text', 'make_comment_clickable', 9, 2 ); 148 add_filter( 'comment_text', 'force_balance_tags', 25 ); 149 add_filter( 'comment_text', 'convert_smilies', 20 ); 150 add_filter( 'comment_text', 'wpautop', 30 ); 151 151 152 152 add_filter( 'comment_excerpt', 'convert_chars' ); 153 153 … … 169 169 add_filter( 'the_author', 'ent2ncr', 8 ); 170 170 171 171 // Misc filters 172 add_filter( 'option_ping_sites', 'privacy_ping_filter' );173 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop174 add_filter( 'option_blog_charset', '_canonical_charset' );175 add_filter( 'option_home', '_config_wp_home' );176 add_filter( 'option_siteurl', '_config_wp_siteurl' );177 add_filter( 'tiny_mce_before_init', '_mce_set_direction' );178 add_filter( 'pre_kses', 'wp_pre_kses_less_than' );179 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 );180 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 );181 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 );182 add_filter( 'pre_comment_content', 'wp_ rel_nofollow', 15);183 add_filter( 'comment_email', 'antispambot' );184 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' );185 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' );186 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 );187 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );188 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );189 add_filter( 'editable_slug', 'urldecode' );190 add_filter( 'editable_slug', 'esc_textarea' );191 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' );192 add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' );193 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' );172 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 173 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop 174 add_filter( 'option_blog_charset', '_canonical_charset' ); 175 add_filter( 'option_home', '_config_wp_home' ); 176 add_filter( 'option_siteurl', '_config_wp_siteurl' ); 177 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 178 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 179 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 180 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 181 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 182 add_filter( 'pre_comment_content', 'wp_maybe_rel_nofollow_comment', 15, 2 ); 183 add_filter( 'comment_email', 'antispambot' ); 184 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); 185 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); 186 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 ); 187 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 188 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 189 add_filter( 'editable_slug', 'urldecode' ); 190 add_filter( 'editable_slug', 'esc_textarea' ); 191 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 192 add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' ); 193 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); 194 194 195 195 add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); 196 196 -
wp-includes/formatting.php
1802 1802 if ( empty($url) ) 1803 1803 return $matches[0]; 1804 1804 1805 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;1805 return $matches[1] . "<a href=\"$url\">$url</a>" . $suffix; 1806 1806 } 1807 1807 1808 1808 /** … … 1830 1830 $ret = substr($dest, -1); 1831 1831 $dest = substr($dest, 0, strlen($dest)-1); 1832 1832 } 1833 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";1833 return $matches[1] . "<a href=\"$dest\">$dest</a>$ret"; 1834 1834 } 1835 1835 1836 1836 /** … … 1921 1921 } 1922 1922 1923 1923 /** 1924 * Convert plaintext URI to HTML links in comments. 1925 * 1926 * @since 4.1.0 1927 * 1928 * @param object $comment A comment. 1929 * @return string Content with converted URIs. 1930 * 1931 */ 1932 function make_comment_clickable( $text, $comment ) { 1933 $text = make_clickable( $text ); 1934 $user_id = $maybe_comment->user_id > 0 ? $comment->user_id : null; 1935 return wp_maybe_rel_nofollow_comment( $ret, $user_id, 'unescaped' ); 1936 } 1937 1938 /** 1924 1939 * Breaks a string into chunks by splitting at whitespace characters. 1925 1940 * The length of each returned chunk is as close to the specified length goal as possible, 1926 1941 * with the caveat that each chunk includes its trailing delimiter. … … 1979 1994 } 1980 1995 1981 1996 /** 1997 * Controls weather there is a rel=nofollow string in all HTML A elements 1998 * in a comment, depending on if the user can edit comments or not. 1999 * 2000 * @since 4.1.0 2001 * 2002 * @param string $text HTML text to filter 2003 * @param int $author_id User ID of the author of the comment 2004 * @param string $excaped 'escaped' if the $text is already escaped, else 'unescaped' 2005 * 2006 */ 2007 function wp_maybe_rel_nofollow_comment( $text, $author_id = null, $escaped = 'escaped' ) { 2008 // Test for authors that can edit comments. 2009 if ( null != $author_id && user_can( $author_id, 'edit_comment' ) ) { 2010 // No need to add rel=nofollow. 2011 return $text; 2012 } 2013 2014 return wp_rel_nofollow( $text, $escaped ); 2015 } 2016 2017 /** 1982 2018 * Adds rel nofollow string to all HTML A elements in content. 1983 2019 * 1984 2020 * @since 1.5.0 … … 1986 2022 * @param string $text Content that may contain HTML A elements. 1987 2023 * @return string Converted content. 1988 2024 */ 1989 function wp_rel_nofollow( $text ) { 1990 // This is a pre save filter, so text is already escaped. 1991 $text = stripslashes($text); 1992 $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); 1993 $text = wp_slash($text); 2025 function wp_rel_nofollow( $text, $escaped = 'escaped' ) { 2026 if ( 'escaped' == $escaped ) { 2027 $text = stripslashes( $text ); 2028 } 2029 $text = preg_replace_callback( '|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text ); 2030 if ( 'escaped' == $escaped ) { 2031 $text = wp_slash( $text ); 2032 } 1994 2033 return $text; 1995 2034 } 1996 2035 … … 2007 2046 */ 2008 2047 function wp_rel_nofollow_callback( $matches ) { 2009 2048 $text = $matches[1]; 2010 $text = str_replace( array(' rel="nofollow"', " rel='nofollow'"), '', $text);2049 $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'" ), '', $text ); 2011 2050 return "<a $text rel=\"nofollow\">"; 2012 2051 } 2013 2052