WordPress.org

Make WordPress Core

Changeset 37743


Ignore:
Timestamp:
06/17/2016 09:47:58 PM (4 years ago)
Author:
rachelbaker
Message:

Comments: Wrap or unwrap the List Table comment_date as comment status changes via Ajax.

Introduced in [36521].

Fixes #36742.
Props imath, adamsilverstein.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r37741 r37743  
    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   = '';
     359
     360        if ( $comment ) {
     361            $comment_status = $comment->comment_approved;
     362        }
     363
     364        if ( 1 === (int) $comment_status ) {
     365            $comment_link = get_comment_link( $comment );
     366        }
    357367
    358368        $counts = wp_count_comments();
     
    363373            'id' => $comment_id,
    364374            'supplemental' => array(
    365                 'status' => $comment ? $comment->comment_approved : '',
     375                'status' => $comment_status,
    366376                'postId' => $comment ? $comment->comment_post_ID : '',
    367377                'time' => $time,
     
    374384                    _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
    375385                    number_format_i18n( $counts->moderated )
    376                 )
     386                ),
     387                'comment_link' => $comment_link,
    377388            )
    378389        ) );
  • trunk/src/wp-includes/js/wp-lists.js

    r36286 r37743  
    298298            rres = r;
    299299
     300            if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {
     301                var submittedOn = element.find( '.submitted-on' ),
     302                    commentLink = submittedOn.find( 'a' );
     303
     304                // Comment is approved; link the date field.
     305                if ( '' !== res.responses[0].supplemental.comment_link ) {
     306                    submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', res.responses[0].supplemental.comment_link ) );
     307
     308                // Comment is not approved; unlink the date field.
     309                } else if ( commentLink.length ) {
     310                    submittedOn.text( commentLink.text() );
     311                }
     312            }
     313
    300314            if ( !res || res.errors ) {
    301315                element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
Note: See TracChangeset for help on using the changeset viewer.