Update comments count for Pending and Spam on edit-comments.php and the dashboard, fixes #8227
git-svn-id: http://svn.automattic.com/wordpress/trunk@9720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9d6e621b2d
commit
a9d45e28cf
|
@ -120,9 +120,9 @@ $num_comments = wp_count_comments();
|
||||||
//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
|
//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
|
||||||
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
|
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
|
||||||
$stati = array(
|
$stati = array(
|
||||||
'moderated' => __ngettext_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>'),
|
'moderated' => __ngettext_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
|
||||||
'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
|
'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
|
||||||
'spam' => __ngettext_noop('Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>')
|
'spam' => __ngettext_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)')
|
||||||
);
|
);
|
||||||
$class = ( '' === $comment_status ) ? ' class="current"' : '';
|
$class = ( '' === $comment_status ) ? ' class="current"' : '';
|
||||||
$status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
|
$status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
|
||||||
|
|
|
@ -236,7 +236,7 @@ function wp_dashboard_right_now() {
|
||||||
// Spam Comments
|
// Spam Comments
|
||||||
$num = number_format_i18n($num_comm['spam']);
|
$num = number_format_i18n($num_comm['spam']);
|
||||||
if ( current_user_can( 'moderate_comments' ) )
|
if ( current_user_can( 'moderate_comments' ) )
|
||||||
$num = "<a href='edit-comments.php?comment_status=spam'>$num</a>";
|
$num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
|
||||||
echo '<td class="b b-spam">'.$num.'</td>';
|
echo '<td class="b b-spam">'.$num.'</td>';
|
||||||
echo '<td class="last t spam">' . __ngettext( 'Spam', 'Spam', $num_comm['spam'] ) . '</td>';
|
echo '<td class="last t spam">' . __ngettext( 'Spam', 'Spam', $num_comm['spam'] ) . '</td>';
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ function wp_dashboard_right_now() {
|
||||||
// Pending Comments
|
// Pending Comments
|
||||||
$num = number_format_i18n($num_comm['awaiting_moderation']);
|
$num = number_format_i18n($num_comm['awaiting_moderation']);
|
||||||
if ( current_user_can( 'moderate_comments' ) )
|
if ( current_user_can( 'moderate_comments' ) )
|
||||||
$num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";
|
$num = "<a href='edit-comments.php?comment_status=moderated'><span class='pending-count'>$num</span></a>";
|
||||||
echo '<td class="b b-waiting">'.$num.'</td>';
|
echo '<td class="b b-waiting">'.$num.'</td>';
|
||||||
echo '<td class="last t waiting">' . __ngettext( 'Pending', 'Pending', $num_comm['awaiting_moderation'] ) . '</td>';
|
echo '<td class="last t waiting">' . __ngettext( 'Pending', 'Pending', $num_comm['awaiting_moderation'] ) . '</td>';
|
||||||
|
|
||||||
|
|
|
@ -10,37 +10,22 @@ setCommentsList = function() {
|
||||||
else
|
else
|
||||||
c.find('div.comment_status').html('1')
|
c.find('div.comment_status').html('1')
|
||||||
|
|
||||||
$('li span.comment-count').each( function() {
|
$('span.pending-count').each( function() {
|
||||||
var a = $(this);
|
var a = $(this);
|
||||||
var n = parseInt(a.html(),10);
|
var n = parseInt(a.html(),10);
|
||||||
|
if ( isNaN(n) ) return;
|
||||||
n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
||||||
if ( n < 0 ) { n = 0; }
|
if ( n < 0 ) { n = 0; }
|
||||||
a.html( n.toString() );
|
a.html( n.toString() );
|
||||||
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
||||||
});
|
});
|
||||||
$('.post-com-count span.comment-count').each( function() {
|
|
||||||
var a = $(this);
|
|
||||||
var n = parseInt(a.html(),10);
|
|
||||||
var t = parseInt(a.parent().attr('title'), 10);
|
|
||||||
if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
|
|
||||||
n = n - 1;
|
|
||||||
t = t + 1;
|
|
||||||
} else { // we approved a formerly unapproved comment
|
|
||||||
n = n + 1;
|
|
||||||
t = t - 1;
|
|
||||||
}
|
|
||||||
if ( n < 0 ) { n = 0; }
|
|
||||||
if ( t < 0 ) { t = 0; }
|
|
||||||
if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
|
|
||||||
if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
|
|
||||||
a.html( n.toString() );
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var delAfter = function( r, settings ) {
|
var delAfter = function( r, settings ) {
|
||||||
$('li span.comment-count').each( function() {
|
$('span.pending-count').each( function() {
|
||||||
var a = $(this);
|
var a = $(this);
|
||||||
var n = parseInt(a.html(),10);
|
var n = parseInt(a.html(),10);
|
||||||
|
if ( isNaN(n) ) return;
|
||||||
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
|
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
|
||||||
n = n - 1;
|
n = n - 1;
|
||||||
} else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
|
} else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
|
||||||
|
@ -50,22 +35,11 @@ setCommentsList = function() {
|
||||||
a.html( n.toString() );
|
a.html( n.toString() );
|
||||||
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
||||||
});
|
});
|
||||||
$('.post-com-count span.comment-count').each( function() {
|
|
||||||
var a = $(this);
|
$('span.spam-count' ).each( function() {
|
||||||
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
|
|
||||||
var t = parseInt(a.parent().attr('title'), 10);
|
|
||||||
if ( t < 1 ) { return; }
|
|
||||||
t = t - 1;
|
|
||||||
a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
|
|
||||||
if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var n = parseInt(a.html(),10) - 1;
|
|
||||||
a.html( n.toString() );
|
|
||||||
});
|
|
||||||
$('li span.spam-comment-count' ).each( function() {
|
|
||||||
var a = $(this);
|
var a = $(this);
|
||||||
var n = parseInt(a.html(),10);
|
var n = parseInt(a.html(),10);
|
||||||
|
if ( isNaN(n) ) return;
|
||||||
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
|
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
|
||||||
n = n + 1;
|
n = n + 1;
|
||||||
} else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
|
} else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
|
||||||
|
|
|
@ -50,7 +50,7 @@ $menu[20] = array( __('Pages'), 'edit_pages', 'page-new.php', '', 'menu-top', 'm
|
||||||
//$submenu['page-new.php'][10] = array( __('Drafts'), 'edit_pages', 'edit-page-drafts.php' );
|
//$submenu['page-new.php'][10] = array( __('Drafts'), 'edit_pages', 'edit-page-drafts.php' );
|
||||||
$submenu['page-new.php'][15] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
|
$submenu['page-new.php'][15] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
|
||||||
|
|
||||||
$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
|
$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
|
||||||
|
|
||||||
$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
|
$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'good' => __('Medium'),
|
'good' => __('Medium'),
|
||||||
'strong' => __('Strong')
|
'strong' => __('Strong')
|
||||||
) );
|
) );
|
||||||
$scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081114' );
|
$scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081115' );
|
||||||
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
|
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
|
||||||
'pending' => __('%i% pending'), // must look like: "# blah blah"
|
'pending' => __('%i% pending'), // must look like: "# blah blah"
|
||||||
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
|
||||||
|
|
Loading…
Reference in New Issue