Make WordPress Core

Ticket #44485: comment-template.php.2.patch

File comment-template.php.2.patch, 11.8 KB (added by tristanleboss, 6 years ago)

Latest patch with all functions done

  • wp-includes/comment-template.php

     
    824824 * Display the link to the current post comments.
    825825 *
    826826 * @since 0.71
     827 * @since 4.9.7 Added the `$post_id` parameter.
    827828 *
    828829 * @param string $deprecated   Not Used.
    829830 * @param string $deprecated_2 Not Used.
     831 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    830832 */
    831 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
     833function comments_link( $deprecated = '', $deprecated_2 = '', $post_id = 0 ) {
    832834        if ( ! empty( $deprecated ) ) {
    833835                _deprecated_argument( __FUNCTION__, '0.72' );
    834836        }
     
    835837        if ( ! empty( $deprecated_2 ) ) {
    836838                _deprecated_argument( __FUNCTION__, '1.3.0' );
    837839        }
    838         echo esc_url( get_comments_link() );
     840        echo esc_url( get_comments_link( $post_id ) );
    839841}
    840842
    841843/**
     
    872874 * Display the language string for the number of comments the current post has.
    873875 *
    874876 * @since 0.71
     877 * @since 4.9.7 Added the `$post_id` parameter.
    875878 *
    876879 * @param string $zero       Optional. Text for no comments. Default false.
    877880 * @param string $one        Optional. Text for one comment. Default false.
    878881 * @param string $more       Optional. Text for more than one comment. Default false.
    879882 * @param string $deprecated Not used.
     883 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    880884 */
    881 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
     885function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $post_id = 0 ) {
    882886        if ( ! empty( $deprecated ) ) {
    883887                _deprecated_argument( __FUNCTION__, '1.3.0' );
    884888        }
    885         echo get_comments_number_text( $zero, $one, $more );
     889        echo get_comments_number_text( $zero, $one, $more, $post_id );
    886890}
    887891
    888892/**
     
    889893 * Display the language string for the number of comments the current post has.
    890894 *
    891895 * @since 4.0.0
     896 * @since 4.9.7 Added the `$post_id` parameter.
    892897 *
    893898 * @param string $zero Optional. Text for no comments. Default false.
    894899 * @param string $one  Optional. Text for one comment. Default false.
    895900 * @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.
    896902 */
    897 function get_comments_number_text( $zero = false, $one = false, $more = false ) {
    898         $number = get_comments_number();
     903function get_comments_number_text( $zero = false, $one = false, $more = false, $post_id = 0 ) {
     904        $number = get_comments_number( $post_id );
    899905
    900906        if ( $number > 1 ) {
    901907                if ( false === $more ) {
     
    10091015 * Retrieve the comment time of the current comment.
    10101016 *
    10111017 * @since 1.5.0
     1018 * @since 4.9.7 Added the `$comment_ID` parameter.
    10121019 *
    10131020 * @param string $d         Optional. The format of the time. Default user's settings.
    10141021 * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
    10151022 * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
    10161023 *                          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.
    10171026 * @return string The formatted time.
    10181027 */
    1019 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
    1020         $comment = get_comment();
     1028function get_comment_time( $d = '', $gmt = false, $translate = true, $comment_ID = 0 ) {
     1029        $comment = get_comment( $comment_ID );
    10211030
     1031        if ( null === $comment ) {
     1032                return '';
     1033        }
     1034
    10221035        $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
    10231036        if ( '' == $d ) {
    10241037                $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
     
    10441057 * Display the comment time of the current comment.
    10451058 *
    10461059 * @since 0.71
     1060 * @since 4.9.7 Added the `$comment_ID` parameter.
    10471061 *
    10481062 * @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.
    10491065 */
    1050 function comment_time( $d = '' ) {
    1051         echo get_comment_time( $d );
     1066function comment_time( $d = '', $comment_ID = 0 ) {
     1067        echo get_comment_time( $d, false, true, $comment_ID );
    10521068}
    10531069
    10541070/**
     
    10841100 * Display the comment type of the current comment.
    10851101 *
    10861102 * @since 0.71
     1103 * @since 4.9.7 Added the `$comment_ID` parameter.
    10871104 *
    10881105 * @param string $commenttxt   Optional. String to display for comment type. Default false.
    10891106 * @param string $trackbacktxt Optional. String to display for trackback type. Default false.
    10901107 * @param string $pingbacktxt  Optional. String to display for pingback type. Default false.
     1108 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to print the text.
     1109 *                                    Default current comment.
    10911110 */
    1092 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
     1111function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false, $comment_ID = 0 ) {
    10931112        if ( false === $commenttxt ) {
    10941113                $commenttxt = _x( 'Comment', 'noun' );
    10951114        }
     
    10991118        if ( false === $pingbacktxt ) {
    11001119                $pingbacktxt = __( 'Pingback' );
    11011120        }
    1102         $type = get_comment_type();
     1121        $type = get_comment_type( $comment_ID );
    11031122        switch ( $type ) {
    11041123                case 'trackback':
    11051124                        echo $trackbacktxt;
     
    11201139 * current post is used and appended to the correct page to go to.
    11211140 *
    11221141 * @since 1.5.0
     1142 * @since 4.9.7 Added the `$post_id` parameter.
    11231143 *
     1144 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    11241145 * @return string The trackback URL after being filtered.
    11251146 */
    1126 function get_trackback_url() {
     1147function get_trackback_url( $post_id = 0 ) {
     1148        if ( empty( $post_id ) ) {
     1149                $post_id = get_the_ID();
     1150        }
     1151
    11271152        if ( '' != get_option( 'permalink_structure' ) ) {
    1128                 $tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' );
     1153                $tb_url = trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( 'trackback', 'single_trackback' );
    11291154        } else {
    1130                 $tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID();
     1155                $tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . $post_id;
    11311156        }
    11321157
    11331158        /**
     
    11441169 * Display the current post's trackback URL.
    11451170 *
    11461171 * @since 0.71
     1172 * @since 4.9.7 Added the `$post_id` parameter.
    11471173 *
    11481174 * @param bool $deprecated_echo Not used.
     1175 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    11491176 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
    11501177 *                     for the result instead.
    11511178 */
    1152 function trackback_url( $deprecated_echo = true ) {
     1179function trackback_url( $deprecated_echo = true, $post_id = 0 ) {
    11531180        if ( true !== $deprecated_echo ) {
    11541181                _deprecated_argument(
    11551182                        __FUNCTION__, '2.5.0',
     
    11621189        }
    11631190
    11641191        if ( $deprecated_echo ) {
    1165                 echo get_trackback_url();
     1192                echo get_trackback_url( $post_id );
    11661193        } else {
    1167                 return get_trackback_url();
     1194                return get_trackback_url( $post_id );
    11681195        }
    11691196}
    11701197
     
    11741201 * Deprecated in 3.0.0, and restored in 3.0.1.
    11751202 *
    11761203 * @since 0.71
     1204 * @since 4.9.7 Added the `$post_id` parameter.
    11771205 *
    11781206 * @param int $deprecated Not used (Was $timezone = 0).
     1207 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    11791208 */
    1180 function trackback_rdf( $deprecated = '' ) {
     1209function trackback_rdf( $deprecated = '', $post_id = 0 ) {
    11811210        if ( ! empty( $deprecated ) ) {
    11821211                _deprecated_argument( __FUNCTION__, '2.5.0' );
    11831212        }
     
    11861215                return;
    11871216        }
    11881217
     1218        if ( empty( $post_id ) ) {
     1219                $post_id = get_the_ID();
     1220        }
     1221
    11891222        echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    11901223                        xmlns:dc="http://purl.org/dc/elements/1.1/"
    11911224                        xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
    11921225                <rdf:Description rdf:about="';
    1193         the_permalink();
     1226        the_permalink( $post_id );
    11941227        echo '"' . "\n";
    11951228        echo '    dc:identifier="';
    1196         the_permalink();
     1229        the_permalink( $post_id );
    11971230        echo '"' . "\n";
    1198         echo '    dc:title="' . str_replace( '--', '&#x2d;&#x2d;', wptexturize( strip_tags( get_the_title() ) ) ) . '"' . "\n";
    1199         echo '    trackback:ping="' . get_trackback_url() . '"' . " />\n";
     1231        echo '    dc:title="' . str_replace( '--', '&#x2d;&#x2d;', wptexturize( strip_tags( get_the_title( $post_id ) ) ) ) . '"' . "\n";
     1232        echo '    trackback:ping="' . get_trackback_url( $post_id ) . '"' . " />\n";
    12001233        echo '</rdf:RDF>';
    12011234}
    12021235
     
    12731306 * Backported to 2.0.10.
    12741307 *
    12751308 * @since 2.1.3
     1309 * @since 4.9.7 Added the `$post_id` parameter.
     1310 *
     1311 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    12761312 */
    1277 function wp_comment_form_unfiltered_html_nonce() {
    1278         $post    = get_post();
    1279         $post_id = $post ? $post->ID : 0;
     1313function wp_comment_form_unfiltered_html_nonce( $post_id = 0 ) {
     1314        if ( empty( $post_id ) ) {
     1315                $post_id = get_the_ID();
     1316        }
    12801317
     1318        if ( false === $post_id ) {
     1319                $post_id = 0;
     1320        } else {
     1321                $post    = get_post( $post_id );
     1322                $post_id = $post ? $post->ID : 0;
     1323        }
     1324
    12811325        if ( current_user_can( 'unfiltered_html' ) ) {
    12821326                wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
    12831327                echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n";
     
    15141558 * Displays the link to the comments for the current post ID.
    15151559 *
    15161560 * @since 0.71
     1561 * @since 4.9.7 Added the `$post_id` parameter.
    15171562 *
    15181563 * @param string $zero      Optional. String to display when no comments. Default false.
    15191564 * @param string $one       Optional. String to display when only one comment is available.
     
    15231568 * @param string $css_class Optional. CSS class to use for comments. Default empty.
    15241569 * @param string $none      Optional. String to display when comments have been turned off.
    15251570 *                          Default false.
     1571 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    15261572 */
    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();
     1573function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false, $post_id = 0 ) {
     1574        if ( empty( $post_id ) ) {
     1575                $id = get_the_ID();
     1576        } else {
     1577                $id = $post_id;
     1578        }
     1579
     1580        $title  = get_the_title( $id );
    15301581        $number = get_comments_number( $id );
    15311582
    15321583        if ( false === $zero ) {
     
    15501601                $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
    15511602        }
    15521603
    1553         if ( 0 == $number && ! comments_open() && ! pings_open() ) {
     1604        if ( 0 == $number && ! comments_open( $id ) && ! pings_open( $id ) ) {
    15541605                echo '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>';
    15551606                return;
    15561607        }
    15571608
    1558         if ( post_password_required() ) {
     1609        if ( post_password_required( $id ) ) {
    15591610                _e( 'Enter your password to view comments.' );
    15601611                return;
    15611612        }
     
    15621613
    15631614        echo '<a href="';
    15641615        if ( 0 == $number ) {
    1565                 $respond_link = get_permalink() . '#respond';
     1616                $respond_link = get_permalink( $id ) . '#respond';
    15661617                /**
    15671618                 * Filters the respond link when a post has no comments.
    15681619                 *
     
    15731624                 */
    15741625                echo apply_filters( 'respond_link', $respond_link, $id );
    15751626        } else {
    1576                 comments_link();
     1627                comments_link( '', '', $id );
    15771628        }
    15781629        echo '"';
    15791630
     
    15921643        echo apply_filters( 'comments_popup_link_attributes', $attributes );
    15931644
    15941645        echo '>';
    1595         comments_number( $zero, $one, $more );
     1646        comments_number( $zero, $one, $more, '', $id );
    15961647        echo '</a>';
    15971648}
    15981649