Make WordPress Core

Ticket #36742: 36742.2.patch

File 36742.2.patch, 2.7 KB (added by adamsilverstein, 9 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    352352
    353353        // JS didn't send us everything we need to know. Just die with success message
    354354        if ( ! $total || ! $per_page || ! $page || ! $url ) {
    355                 $time = time();
    356                 $comment = get_comment( $comment_id );
     355                $time           = time();
     356                $comment        = get_comment( $comment_id );
     357                $comment_status = '';
     358                $comment_link   = '';
    357359
     360                if ( $comment ) {
     361                        $comment_status = $comment->comment_approved;
     362                }
     363
     364                // If the comment is approved, add a link to the comment so the JavaScript can link the date.
     365                if ( 1 === (int) $comment_status ) {
     366                        $comment_link = get_comment_link( $comment );
     367                }
     368
    358369                $counts = wp_count_comments();
    359370
    360371                $x = new WP_Ajax_Response( array(
     
    362373                        // Here for completeness - not used.
    363374                        'id' => $comment_id,
    364375                        'supplemental' => array(
    365                                 'status' => $comment ? $comment->comment_approved : '',
     376                                'status' => $comment_status,
    366377                                'postId' => $comment ? $comment->comment_post_ID : '',
    367378                                'time' => $time,
    368379                                'in_moderation' => $counts->moderated,
     
    373384                                'i18n_moderation_text' => sprintf(
    374385                                        _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
    375386                                        number_format_i18n( $counts->moderated )
    376                                 )
     387                                ),
     388                                'comment_link' => $comment_link,
    377389                        )
    378390                ) );
    379391                $x->send();
  • src/wp-includes/js/wp-lists.js

     
    297297                        res = wpAjax.parseAjaxResponse(r, s.response, s.element);
    298298                        rres = r;
    299299
     300                        // Handle the specific case for the "submitted on" link of Comments List Table.
     301                        if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {
     302                                var submittedOn = element.find( '.submitted-on' ),
     303                                        commentLink = submittedOn.find( 'a' );
     304
     305                                // Comment is approved; link the date field.
     306                                if ( '' !== res.responses[0].supplemental.comment_link ) {
     307                                        submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', res.responses[0].supplemental.comment_link ) );
     308
     309                                // Comment is not approved; unlink the dte field.
     310                                } else if ( commentLink.length ) {
     311                                        submittedOn.text( commentLink.text() );
     312                                }
     313                        }
     314
    300315                        if ( !res || res.errors ) {
    301316                                element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
    302317                                return false;