Comments: Ensure the correct comment ID is passed to the get_comment_author_url
filter.
Props dominik.schwind Fixes #41334 git-svn-id: https://develop.svn.wordpress.org/trunk@41127 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a661557bce
commit
7a965fcfe6
@ -306,7 +306,7 @@ function get_comment_author_url( $comment_ID = 0 ) {
|
|||||||
if ( ! empty( $comment ) ) {
|
if ( ! empty( $comment ) ) {
|
||||||
$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
|
$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
|
||||||
$url = esc_url( $author_url, array( 'http', 'https' ) );
|
$url = esc_url( $author_url, array( 'http', 'https' ) );
|
||||||
$id = $comment->ID;
|
$id = $comment->comment_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
27
tests/phpunit/tests/comment/getCommentAuthorUrl.php
Normal file
27
tests/phpunit/tests/comment/getCommentAuthorUrl.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group comment
|
||||||
|
*/
|
||||||
|
class Tests_Comment_GetCommentAuthorUrl extends WP_UnitTestCase {
|
||||||
|
public function get_comment_author_url_filter( $url, $id, $comment ) {
|
||||||
|
$this->assertSame( $id, $comment->comment_ID );
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 41334
|
||||||
|
*/
|
||||||
|
public function test_comment_author_url_passes_correct_comment_id() {
|
||||||
|
$comment = self::factory()->comment->create_and_get( array(
|
||||||
|
'comment_post_ID' => 0,
|
||||||
|
) );
|
||||||
|
|
||||||
|
add_filter( 'get_comment_author_url', array( $this, 'get_comment_author_url_filter' ), 99, 3 );
|
||||||
|
|
||||||
|
get_comment_author_url( $comment );
|
||||||
|
|
||||||
|
remove_filter( 'get_comment_author_url', array( $this, 'get_comment_author_url_filter' ), 99 );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user