#61727 closed enhancement (fixed)
Add `$context` parameter to `get_edit_comment_link()` to get the URL without HTML entities
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | good-first-bug has-patch has-unit-tests commit |
Focuses: | template | Cc: |
Description
The get_edit_comment_link()
function currently always returns its URL with HTML entities included, specifically &
(&
). This makes sense when including the URL in HTML content, but this may not be the only context where such a link is used.
For exactly the same purpose, the get_edit_post_link()
function already has a $context
parameter with a default value of "display". Alternatively, "raw" can be provided to not include the HTML entity &
, but the regular &
.
It would make sense to introduce the same optional $context
parameter to get_edit_comment_link()
. If "raw" is provided, the function could return the URL to edit the comment without the HTML entity.
Change History (19)
This ticket was mentioned in PR #7071 on WordPress/wordpress-develop by @deepakrohilla.
8 months ago
#1
- Keywords has-patch added; needs-patch removed
@deepakrohilla commented on PR #7071:
8 months ago
#3
@felixarntz Thanks for the suggestion , i will update you today EOD for test case. Thanks again!.
@deepakrohilla commented on PR #7071:
8 months ago
#4
@felixarntz : test case also added please review.
@deepakrohilla commented on PR #7071:
8 months ago
#5
@mukeshpanchal27 : Suggested changes performed , please check Thanks!.
#6
@
8 months ago
- Keywords has-unit-tests added; needs-unit-tests removed
- Milestone changed from Future Release to 6.7
@deepakrohilla commented on PR #7071:
8 months ago
#7
@felixarntz Please check it now
@flixos90 commented on PR #7071:
8 months ago
#9
Committed in https://core.trac.wordpress.org/changeset/58875
#10
@
6 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
Sorry for reopening the ticket, but I've run into an issue where the $comment_id
passed as an optional argument to the get_edit_comment_link
filter callback is not an int
but an object of the WP_Comment
class.
This happens in case the object is passed as an argument to the get_edit_comment_link
function. The docblock of the get_edit_comment_link
function and it's implementation actually allows the WP_Commnet
object to be passed in instead of an int
.
IMHO, either the documentation of the get_edit_comment_link
filter needs to be updated the way it matches such behaviour, or the code needs to be updated the way it ensures the $comment_id
param is always an int
.
This ticket was mentioned in PR #7322 on WordPress/wordpress-develop by @flixos90.
6 months ago
#11
This is a follow-up fix that addresses the bug in https://core.trac.wordpress.org/ticket/61727#comment:10.
Trac ticket: https://core.trac.wordpress.org/ticket/61727
#12
@
6 months ago
Thanks @davidbinda, this is a great catch. I implemented a fix in https://github.com/WordPress/wordpress-develop/pull/7322 that ensures the parameter is always the comment ID, which makes more sense for consistent filter behavior.
@peterwilsoncc commented on PR #7322:
6 months ago
#13
@felixarntz This looks good to me but are you able to do a force push of just the test, wait for the actions to complete and then push the fix?
@flixos90 commented on PR #7322:
6 months ago
#14
@peterwilsoncc Done, please see e.g. https://github.com/WordPress/wordpress-develop/actions/runs/10802717139/job/29965357479?pr=7322 for showing the failing test prior to the fix being re-added.
#15
@
6 months ago
- Keywords commit added
Great catch @davidbinda
The PR got enough approval for commit.
#16
@
6 months ago
Thank you, @davidbinda, for catching that, and thanks to @felixarntz for implementing it further.
@flixos90 commented on PR #7322:
6 months ago
#18
Committed in https://core.trac.wordpress.org/changeset/59012
Add
$context
parameter toget_edit_comment_link()
to get the URL without HTML entities