Changeset 58875
- Timestamp:
- 08/09/2024 05:59:41 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r58822 r58875 1596 1596 * 1597 1597 * @since 2.3.0 1598 * @since 6.7.0 The $context parameter was added. 1598 1599 * 1599 1600 * @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object. 1600 * @return string|void The edit comment link URL for the given comment. 1601 */ 1602 function get_edit_comment_link( $comment_id = 0 ) { 1601 * @param string $context Optional. Context in which the URL should be used. Either 'display', 1602 * to include HTML entities, or 'url'. Default 'display'. 1603 * @return string|void The edit comment link URL for the given comment, or void if the comment id does not exist or 1604 * the current user is not allowed to edit it. 1605 */ 1606 function get_edit_comment_link( $comment_id = 0, $context = 'display' ) { 1603 1607 $comment = get_comment( $comment_id ); 1604 1608 1605 if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {1609 if ( ! is_object( $comment ) || ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { 1606 1610 return; 1607 1611 } 1608 1612 1609 $location = admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID; 1613 if ( 'display' === $context ) { 1614 $action = 'comment.php?action=editcomment&c='; 1615 } else { 1616 $action = 'comment.php?action=editcomment&c='; 1617 } 1618 1619 $location = admin_url( $action ) . $comment->comment_ID; 1610 1620 1611 1621 /** 1612 1622 * Filters the comment edit link. 1613 1623 * 1614 * @since 2.3.01624 * @since 6.7.0 The $comment_id and $context parameters are now being passed to the filter. 1615 1625 * 1616 1626 * @param string $location The edit link. 1617 */ 1618 return apply_filters( 'get_edit_comment_link', $location ); 1627 * @param int $comment_id Optional. Unique ID of the comment to generate an edit link. 1628 * @param int $context Optional. Context to include HTML entities in link. Default 'display'. 1629 */ 1630 return apply_filters( 'get_edit_comment_link', $location, $comment_id, $context ); 1619 1631 } 1620 1632
Note: See TracChangeset
for help on using the changeset viewer.