Comments: Wrap or unwrap the List Table comment_date as comment status changes via Ajax.
Introduced in [36521]. Fixes #36742. Props imath, adamsilverstein. git-svn-id: https://develop.svn.wordpress.org/trunk@37743 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
090ecc34f9
commit
cf783103fc
|
@ -354,6 +354,16 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||||
if ( ! $total || ! $per_page || ! $page || ! $url ) {
|
if ( ! $total || ! $per_page || ! $page || ! $url ) {
|
||||||
$time = time();
|
$time = time();
|
||||||
$comment = get_comment( $comment_id );
|
$comment = get_comment( $comment_id );
|
||||||
|
$comment_status = '';
|
||||||
|
$comment_link = '';
|
||||||
|
|
||||||
|
if ( $comment ) {
|
||||||
|
$comment_status = $comment->comment_approved;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 1 === (int) $comment_status ) {
|
||||||
|
$comment_link = get_comment_link( $comment );
|
||||||
|
}
|
||||||
|
|
||||||
$counts = wp_count_comments();
|
$counts = wp_count_comments();
|
||||||
|
|
||||||
|
@ -362,7 +372,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||||
// Here for completeness - not used.
|
// Here for completeness - not used.
|
||||||
'id' => $comment_id,
|
'id' => $comment_id,
|
||||||
'supplemental' => array(
|
'supplemental' => array(
|
||||||
'status' => $comment ? $comment->comment_approved : '',
|
'status' => $comment_status,
|
||||||
'postId' => $comment ? $comment->comment_post_ID : '',
|
'postId' => $comment ? $comment->comment_post_ID : '',
|
||||||
'time' => $time,
|
'time' => $time,
|
||||||
'in_moderation' => $counts->moderated,
|
'in_moderation' => $counts->moderated,
|
||||||
|
@ -373,7 +383,8 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||||
'i18n_moderation_text' => sprintf(
|
'i18n_moderation_text' => sprintf(
|
||||||
_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
|
_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
|
||||||
number_format_i18n( $counts->moderated )
|
number_format_i18n( $counts->moderated )
|
||||||
)
|
),
|
||||||
|
'comment_link' => $comment_link,
|
||||||
)
|
)
|
||||||
) );
|
) );
|
||||||
$x->send();
|
$x->send();
|
||||||
|
|
|
@ -297,6 +297,20 @@ wpList = {
|
||||||
res = wpAjax.parseAjaxResponse(r, s.response, s.element);
|
res = wpAjax.parseAjaxResponse(r, s.response, s.element);
|
||||||
rres = r;
|
rres = r;
|
||||||
|
|
||||||
|
if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {
|
||||||
|
var submittedOn = element.find( '.submitted-on' ),
|
||||||
|
commentLink = submittedOn.find( 'a' );
|
||||||
|
|
||||||
|
// Comment is approved; link the date field.
|
||||||
|
if ( '' !== res.responses[0].supplemental.comment_link ) {
|
||||||
|
submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', res.responses[0].supplemental.comment_link ) );
|
||||||
|
|
||||||
|
// Comment is not approved; unlink the date field.
|
||||||
|
} else if ( commentLink.length ) {
|
||||||
|
submittedOn.text( commentLink.text() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !res || res.errors ) {
|
if ( !res || res.errors ) {
|
||||||
element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
|
element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue