Ticket #11359: 11359.4.diff
File 11359.4.diff, 10.0 KB (added by , 10 years ago) |
---|
-
wp-includes/comment-functions.php
1482 1482 * 1483 1483 * @param int $comment_content The comment content. 1484 1484 */ 1485 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );1485 $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'], isset( $commentdata['user_id'] ) ? $commentdata['user_id'] : null ); 1486 1486 /** 1487 1487 * Filter the comment author's IP before it is set. 1488 1488 * -
wp-includes/comment-template.php
210 210 $url = get_comment_author_url( $comment ); 211 211 $author = get_comment_author( $comment ); 212 212 213 if ( empty( $url ) || 'http://' == $url ) 213 if ( empty( $url ) || 'http://' == $url ) { 214 214 $return = $author; 215 else 216 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; 215 } else { 216 // By default, add rel=nofollow to author links 217 $nofollow = ' nofollow'; 218 $comment = get_comment( $comment_ID ); 219 // If the author can edit comments, no need to rel=unfollow the link 220 if ( $comment->user_id > 0 && user_can( $comment->user_id, 'edit_comment' ) ) { 221 $nofollow = ''; 222 } 217 223 224 $return = "<a href='$url' rel='external$nofollow' class='url'>$author</a>"; 225 } 226 218 227 /** 219 228 * Filter the comment author's link for display. 220 229 * -
wp-includes/default-filters.php
143 143 add_filter( 'the_excerpt', 'shortcode_unautop'); 144 144 add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); 145 145 146 add_filter( 'comment_text', 'wptexturize' );147 add_filter( 'comment_text', 'convert_chars' );148 add_filter( 'comment_text', 'make_c lickable', 9);149 add_filter( 'comment_text', 'force_balance_tags', 25);150 add_filter( 'comment_text', 'convert_smilies', 20);151 add_filter( 'comment_text', 'wpautop', 30);146 add_filter( 'comment_text', 'wptexturize' ); 147 add_filter( 'comment_text', 'convert_chars' ); 148 add_filter( 'comment_text', 'make_comment_clickable', 9, 2 ); 149 add_filter( 'comment_text', 'force_balance_tags', 25 ); 150 add_filter( 'comment_text', 'convert_smilies', 20 ); 151 add_filter( 'comment_text', 'wpautop', 30 ); 152 152 153 153 add_filter( 'comment_excerpt', 'convert_chars' ); 154 154 … … 176 176 add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 177 177 178 178 // Misc filters 179 add_filter( 'option_ping_sites', 'privacy_ping_filter' );180 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop181 add_filter( 'option_blog_charset', '_canonical_charset' );182 add_filter( 'option_home', '_config_wp_home' );183 add_filter( 'option_siteurl', '_config_wp_siteurl' );184 add_filter( 'tiny_mce_before_init', '_mce_set_direction' );185 add_filter( 'teeny_mce_before_init', '_mce_set_direction' );186 add_filter( 'pre_kses', 'wp_pre_kses_less_than' );187 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 );188 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 );189 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 );190 add_filter( 'pre_comment_content', 'wp_ rel_nofollow', 15);191 add_filter( 'comment_email', 'antispambot' );192 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' );193 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' );194 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 );195 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );196 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );197 add_filter( 'editable_slug', 'urldecode' );198 add_filter( 'editable_slug', 'esc_textarea' );199 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' );200 add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' );201 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' );202 add_filter( 'title_save_pre', 'trim' );203 add_filter( 'get_comment_metadata', 'wp_lazyload_comment_meta', 10, 2 );179 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 180 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop 181 add_filter( 'option_blog_charset', '_canonical_charset' ); 182 add_filter( 'option_home', '_config_wp_home' ); 183 add_filter( 'option_siteurl', '_config_wp_siteurl' ); 184 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 185 add_filter( 'teeny_mce_before_init', '_mce_set_direction' ); 186 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 187 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 188 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 189 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 190 add_filter( 'pre_comment_content', 'wp_maybe_rel_nofollow_comment', 15, 2 ); 191 add_filter( 'comment_email', 'antispambot' ); 192 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); 193 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); 194 add_filter( 'the_posts', '_close_comments_for_old_posts', 10, 2 ); 195 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 196 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 197 add_filter( 'editable_slug', 'urldecode' ); 198 add_filter( 'editable_slug', 'esc_textarea' ); 199 add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 200 add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri' ); 201 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); 202 add_filter( 'title_save_pre', 'trim' ); 203 add_filter( 'get_comment_metadata', 'wp_lazyload_comment_meta', 10, 2 ); 204 204 205 205 add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); 206 206 -
wp-includes/formatting.php
2058 2058 if ( empty($url) ) 2059 2059 return $matches[0]; 2060 2060 2061 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;2061 return $matches[1] . "<a href=\"$url\">$url</a>" . $suffix; 2062 2062 } 2063 2063 2064 2064 /** … … 2086 2086 $ret = substr($dest, -1); 2087 2087 $dest = substr($dest, 0, strlen($dest)-1); 2088 2088 } 2089 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";2089 return $matches[1] . "<a href=\"$dest\">$dest</a>$ret"; 2090 2090 } 2091 2091 2092 2092 /** … … 2176 2176 } 2177 2177 2178 2178 /** 2179 * Convert plaintext URI to HTML links in comments. 2180 * 2181 * @since 4.4.0 2182 * 2183 * @param object $comment A comment. 2184 * @return string Content with converted URIs. 2185 */ 2186 function make_comment_clickable( $text, $comment ) { 2187 $text = make_clickable( $text ); 2188 $user_id = $comment->user_id > 0 ? $comment->user_id : null; 2189 return wp_maybe_rel_nofollow_comment( $text, $user_id, 'unescaped' ); 2190 } 2191 2192 /** 2179 2193 * Breaks a string into chunks by splitting at whitespace characters. 2180 2194 * The length of each returned chunk is as close to the specified length goal as possible, 2181 2195 * with the caveat that each chunk includes its trailing delimiter. … … 2232 2246 } 2233 2247 2234 2248 /** 2249 * Controls whether there is a rel=nofollow string in all HTML A elements 2250 * in a comment, depending on if the user can edit comments or not. 2251 * 2252 * @since 4.1.0 2253 * 2254 * @param string $text HTML text to filter 2255 * @param int $author_id User ID of the author of the comment 2256 * @param string $escaped 'escaped' if the $text is already escaped, else 'unescaped' 2257 */ 2258 function wp_maybe_rel_nofollow_comment( $text, $author_id = null, $escaped = 'escaped' ) { 2259 // Test for authors that can edit comments. 2260 if ( null != $author_id && user_can( $author_id, 'edit_comment' ) ) { 2261 // No need to add rel=nofollow. 2262 return $text; 2263 } 2264 2265 return wp_rel_nofollow( $text, $escaped ); 2266 } 2267 2268 /** 2235 2269 * Adds rel nofollow string to all HTML A elements in content. 2236 2270 * 2237 2271 * @since 1.5.0 2238 2272 * 2239 * @param string $text Content that may contain HTML A elements. 2273 * @param string $text Content that may contain HTML A elements. 2274 * @param string $escaped Whether the text is escaped or unescaped 2240 2275 * @return string Converted content. 2241 2276 */ 2242 function wp_rel_nofollow( $text ) { 2243 // This is a pre save filter, so text is already escaped. 2244 $text = stripslashes($text); 2245 $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); 2246 return wp_slash( $text ); 2277 function wp_rel_nofollow( $text, $escaped = 'escaped' ) { 2278 if ( 'escaped' == $escaped ) { 2279 $text = stripslashes( $text ); 2280 } 2281 $text = preg_replace_callback( '|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text ); 2282 if ( 'escaped' == $escaped ) { 2283 $text = wp_slash( $text ); 2284 } 2285 return $text; 2247 2286 } 2248 2287 2249 2288 /**