Changeset 46564
- Timestamp:
- 10/21/2019 08:39:16 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r46470 r46564 2836 2836 } 2837 2837 2838 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; 2838 if ( 'comment_text' === current_filter() ) { 2839 $rel = 'nofollow ugc'; 2840 } else { 2841 $rel = 'nofollow'; 2842 } 2843 2844 /** 2845 * Filters the rel value that is added to URL matches converted to links. 2846 * 2847 * @since 5.3.0 2848 * 2849 * @param string $rel The rel value. 2850 * @param string $url The matched URL being converted to a link tag. 2851 */ 2852 $rel = apply_filters( 'make_clickable_rel', $rel, $url ); 2853 $rel = esc_attr( $rel ); 2854 2855 return $matches[1] . "<a href=\"$url\" rel=\"$rel\">$url</a>" . $suffix; 2839 2856 } 2840 2857 … … 2866 2883 } 2867 2884 2868 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; 2885 if ( 'comment_text' === current_filter() ) { 2886 $rel = 'nofollow ugc'; 2887 } else { 2888 $rel = 'nofollow'; 2889 } 2890 2891 /** This filter is documented in wp-includes/formatting.php */ 2892 $rel = apply_filters( 'make_clickable_rel', $rel, $dest ); 2893 $rel = esc_attr( $rel ); 2894 2895 return $matches[1] . "<a href=\"$dest\" rel=\"$rel\">$dest</a>$ret"; 2869 2896 } 2870 2897 … … 3149 3176 * @since 5.1.0 3150 3177 * 3151 * @param string The rel values.3178 * @param string $rel The rel values. 3152 3179 * @param string $link_html The matched content of the link tag including all HTML attributes. 3153 3180 */ -
trunk/tests/phpunit/tests/formatting/MakeClickable.php
r42343 r46564 376 376 377 377 /** 378 * @ticket 30162 378 379 * @dataProvider data_script_and_style_tags 379 * @ticket 30162380 380 */ 381 381 public function test_dont_link_script_and_style_tags( $tag ) { … … 400 400 } 401 401 402 /** 403 * @ticket 48022 404 * @dataProvider data_add_rel_ugc_in_comments 405 */ 406 public function test_add_rel_ugc_in_comments( $content, $expected ) { 407 $comment_id = self::factory()->comment->create( 408 array( 409 'comment_content' => $content, 410 ) 411 ); 412 413 ob_start(); 414 comment_text( $comment_id ); 415 $comment_text = ob_get_clean(); 416 417 $this->assertContains( $expected, make_clickable( $comment_text ) ); 418 } 419 420 public function data_add_rel_ugc_in_comments() { 421 return array( 422 array( 423 'http://wordpress.org', 424 '<a href="http://wordpress.org" rel="nofollow ugc">http://wordpress.org</a>', 425 ), 426 array( 427 'www.wordpress.org', 428 '<p><a href="http://www.wordpress.org" rel="nofollow ugc">http://www.wordpress.org</a>', 429 ), 430 ); 431 } 432 402 433 }
Note: See TracChangeset
for help on using the changeset viewer.