WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#22380 closed enhancement (fixed)

Consolidate the API hooks comment

Reported by: momo360modena Owned by: westi
Milestone: 4.1 Priority: normal
Severity: minor Version: 3.4
Component: Comments Keywords: has-patch needs-refresh good-first-bug
Focuses: Cc:

Description

Many functions of API comments have hooks unusable because they do not provide parameters that provides the function.

In general, these functions provides a $comment_ID argument, but it's not present in the hook...

Sample

function comment_author( $comment_ID = 0 ) {
	$author = apply_filters('comment_author', get_comment_author( $comment_ID ) );
	echo $author;
}

Fixed sample :

function comment_author( $comment_ID = 0 ) {
	$author = apply_filters('comment_author', get_comment_author( $comment_ID ), $comment_ID  );
	echo $author;
}

Attachments (2)

improve-hooks-comments.patch (3.8 KB) - added by momo360modena 4 years ago.
22380.diff (7.4 KB) - added by tareq1988 2 years ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
4 years ago

  • Version changed from trunk to 3.4

#2 @jorbin
3 years ago

  • Keywords needs-refresh added
  • Type changed from defect (bug) to enhancement

Thanks for the suggestion momo360modena. Sorry you never got a response.

I like adding additional context to many of these filters. It definitely makes these filters more flexible and opens up a number of possibilities.

Perhaps though it make sense to be consistent with all of them and only include $comment_ID for all of them rather then sometimes including both $comment_ID and $comment.

When refreshing, some of these now have hook docs (which didn't exist when this patch was originally written), so please make sure to add the new @param value.

#3 @jorbin
3 years ago

related: #19849

#4 @boonebgorges
2 years ago

  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to Future Release

These go in as soon as we get a refresh and the docs that jorbin refers to above <3

#5 @boonebgorges
2 years ago

  • Keywords good-first-bug added

@tareq1988
2 years ago

#6 @westi
2 years ago

  • Owner set to westi
  • Resolution set to fixed
  • Status changed from new to closed

In 30092:

Comment Template Tags: Improve the availability of context information in comment template tag filters.

Fixes #22380 props momo360modena, tareq1988.

#7 @DrewAPicture
2 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The hook doc changelogs need to be updated to reflect the newly-added parameters.

#8 @DrewAPicture
2 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 30111:

Update the changelogs for the comment hook parameters added in [30092].

Parameters were added to the get_comment_author, comment_author, get_comment_author_email, author_email, comment_email, get_comment_author_link, get_comment_author_IP, get_comment_author_url, comment_url, get_comment_excerpt, comment_excerpt, get_comment_ID, and get_comment_type filters.

Fixes #22380.

#9 @SergeyBiryukov
2 years ago

  • Milestone changed from Future Release to 4.1
Note: See TracTickets for help on using tickets.