Ticket #44485: comment-template.php.patch
File comment-template.php.patch, 6.7 KB (added by , 5 years ago) |
---|
-
wp-includes/comment-template.php
824 824 * Display the link to the current post comments. 825 825 * 826 826 * @since 0.71 827 * @since 4.9.7 Added the `$post_id` parameter. 827 828 * 828 829 * @param string $deprecated Not Used. 829 830 * @param string $deprecated_2 Not Used. 831 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. 830 832 */ 831 function comments_link( $deprecated = '', $deprecated_2 = '' ) {833 function comments_link( $deprecated = '', $deprecated_2 = '', $post_id = 0 ) { 832 834 if ( ! empty( $deprecated ) ) { 833 835 _deprecated_argument( __FUNCTION__, '0.72' ); 834 836 } … … 835 837 if ( ! empty( $deprecated_2 ) ) { 836 838 _deprecated_argument( __FUNCTION__, '1.3.0' ); 837 839 } 838 echo esc_url( get_comments_link( ) );840 echo esc_url( get_comments_link( $post_id ) ); 839 841 } 840 842 841 843 /** … … 872 874 * Display the language string for the number of comments the current post has. 873 875 * 874 876 * @since 0.71 877 * @since 4.9.7 Added the `$post_id` parameter. 875 878 * 876 879 * @param string $zero Optional. Text for no comments. Default false. 877 880 * @param string $one Optional. Text for one comment. Default false. 878 881 * @param string $more Optional. Text for more than one comment. Default false. 879 882 * @param string $deprecated Not used. 883 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. 880 884 */ 881 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {885 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $post_id = 0 ) { 882 886 if ( ! empty( $deprecated ) ) { 883 887 _deprecated_argument( __FUNCTION__, '1.3.0' ); 884 888 } 885 echo get_comments_number_text( $zero, $one, $more );889 echo get_comments_number_text( $zero, $one, $more, $post_id ); 886 890 } 887 891 888 892 /** … … 889 893 * Display the language string for the number of comments the current post has. 890 894 * 891 895 * @since 4.0.0 896 * @since 4.9.7 Added the `$post_id` parameter. 892 897 * 893 898 * @param string $zero Optional. Text for no comments. Default false. 894 899 * @param string $one Optional. Text for one comment. Default false. 895 900 * @param string $more Optional. Text for more than one comment. Default false. 901 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. 896 902 */ 897 function get_comments_number_text( $zero = false, $one = false, $more = false ) {898 $number = get_comments_number( );903 function get_comments_number_text( $zero = false, $one = false, $more = false, $post_id = 0 ) { 904 $number = get_comments_number( $post_id ); 899 905 900 906 if ( $number > 1 ) { 901 907 if ( false === $more ) { … … 1009 1015 * Retrieve the comment time of the current comment. 1010 1016 * 1011 1017 * @since 1.5.0 1018 * @since 4.9.7 Added the `$comment_ID` parameter. 1012 1019 * 1013 1020 * @param string $d Optional. The format of the time. Default user's settings. 1014 1021 * @param bool $gmt Optional. Whether to use the GMT date. Default false. 1015 1022 * @param bool $translate Optional. Whether to translate the time (for use in feeds). 1016 1023 * Default true. 1024 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to retrieve the text. 1025 * Default current comment. 1017 1026 * @return string The formatted time. 1018 1027 */ 1019 function get_comment_time( $d = '', $gmt = false, $translate = true ) {1020 $comment = get_comment( );1028 function get_comment_time( $d = '', $gmt = false, $translate = true, $comment_ID = 0 ) { 1029 $comment = get_comment( $comment_ID ); 1021 1030 1031 if ( null === $comment ) { 1032 return ''; 1033 } 1034 1022 1035 $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; 1023 1036 if ( '' == $d ) { 1024 1037 $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate ); … … 1044 1057 * Display the comment time of the current comment. 1045 1058 * 1046 1059 * @since 0.71 1060 * @since 4.9.7 Added the `$comment_ID` parameter. 1047 1061 * 1048 1062 * @param string $d Optional. The format of the time. Default user's settings. 1063 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text. 1064 * Default current comment. 1049 1065 */ 1050 function comment_time( $d = '' ) {1051 echo get_comment_time( $d );1066 function comment_time( $d = '', $comment_ID = 0 ) { 1067 echo get_comment_time( $d, false, true, $comment_ID ); 1052 1068 } 1053 1069 1054 1070 /** … … 1514 1530 * Displays the link to the comments for the current post ID. 1515 1531 * 1516 1532 * @since 0.71 1533 * @since 4.9.7 Added the `$post_id` parameter. 1517 1534 * 1518 1535 * @param string $zero Optional. String to display when no comments. Default false. 1519 1536 * @param string $one Optional. String to display when only one comment is available. … … 1523 1540 * @param string $css_class Optional. CSS class to use for comments. Default empty. 1524 1541 * @param string $none Optional. String to display when comments have been turned off. 1525 1542 * Default false. 1543 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. 1526 1544 */ 1527 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 1528 $id = get_the_ID(); 1529 $title = get_the_title(); 1545 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false, $post_id = 0 ) { 1546 if ( empty( $post_id ) ) { 1547 $id = get_the_ID(); 1548 } else { 1549 $id = $post_id; 1550 } 1551 1552 $title = get_the_title( $id ); 1530 1553 $number = get_comments_number( $id ); 1531 1554 1532 1555 if ( false === $zero ) { … … 1550 1573 $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); 1551 1574 } 1552 1575 1553 if ( 0 == $number && ! comments_open( ) && ! pings_open() ) {1576 if ( 0 == $number && ! comments_open( $id ) && ! pings_open( $id ) ) { 1554 1577 echo '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>'; 1555 1578 return; 1556 1579 } 1557 1580 1558 if ( post_password_required( ) ) {1581 if ( post_password_required( $id ) ) { 1559 1582 _e( 'Enter your password to view comments.' ); 1560 1583 return; 1561 1584 } … … 1562 1585 1563 1586 echo '<a href="'; 1564 1587 if ( 0 == $number ) { 1565 $respond_link = get_permalink( ) . '#respond';1588 $respond_link = get_permalink( $id ) . '#respond'; 1566 1589 /** 1567 1590 * Filters the respond link when a post has no comments. 1568 1591 * … … 1573 1596 */ 1574 1597 echo apply_filters( 'respond_link', $respond_link, $id ); 1575 1598 } else { 1576 comments_link( );1599 comments_link( '', '', $id ); 1577 1600 } 1578 1601 echo '"'; 1579 1602 … … 1592 1615 echo apply_filters( 'comments_popup_link_attributes', $attributes ); 1593 1616 1594 1617 echo '>'; 1595 comments_number( $zero, $one, $more );1618 comments_number( $zero, $one, $more, '', $id ); 1596 1619 echo '</a>'; 1597 1620 } 1598 1621