From a9d45e28cfa5388ca112e2153b5ba664c4cc4376 Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 15 Nov 2008 18:57:53 +0000 Subject: [PATCH] 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 --- wp-admin/edit-comments.php | 4 ++-- wp-admin/includes/dashboard.php | 4 ++-- wp-admin/js/edit-comments.js | 40 ++++++--------------------------- wp-admin/menu.php | 2 +- wp-includes/script-loader.php | 2 +- 5 files changed, 13 insertions(+), 39 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 83603f06ae..d87f8b689e 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -120,9 +120,9 @@ $num_comments = wp_count_comments(); //, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), //, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") $stati = array( - 'moderated' => __ngettext_noop('Pending (%s)', 'Pending (%s)'), + 'moderated' => __ngettext_noop('Pending (%s)', 'Pending (%s)'), 'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used - 'spam' => __ngettext_noop('Spam (%s)', 'Spam (%s)') + 'spam' => __ngettext_noop('Spam (%s)', 'Spam (%s)') ); $class = ( '' === $comment_status ) ? ' class="current"' : ''; $status_links[] = "
  • " . __( 'All' ) . ''; diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index cddd7df84b..3da5866ead 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -236,7 +236,7 @@ function wp_dashboard_right_now() { // Spam Comments $num = number_format_i18n($num_comm['spam']); if ( current_user_can( 'moderate_comments' ) ) - $num = "$num"; + $num = "$num"; echo ''.$num.''; echo '' . __ngettext( 'Spam', 'Spam', $num_comm['spam'] ) . ''; @@ -252,7 +252,7 @@ function wp_dashboard_right_now() { // Pending Comments $num = number_format_i18n($num_comm['awaiting_moderation']); if ( current_user_can( 'moderate_comments' ) ) - $num = "$num"; + $num = "$num"; echo ''.$num.''; echo '' . __ngettext( 'Pending', 'Pending', $num_comm['awaiting_moderation'] ) . ''; diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index b26791737a..ef6186ee1b 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -10,37 +10,22 @@ setCommentsList = function() { else c.find('div.comment_status').html('1') - $('li span.comment-count').each( function() { + $('span.pending-count').each( function() { var a = $(this); var n = parseInt(a.html(),10); + if ( isNaN(n) ) return; n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); if ( n < 0 ) { n = 0; } a.html( n.toString() ); $('#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 ) { - $('li span.comment-count').each( function() { + $('span.pending-count').each( function() { var a = $(this); var n = parseInt(a.html(),10); + if ( isNaN(n) ) return; if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment n = n - 1; } 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() ); $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); }); - $('.post-com-count span.comment-count').each( function() { - var a = $(this); - 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() { + + $('span.spam-count' ).each( function() { var a = $(this); var n = parseInt(a.html(),10); + if ( isNaN(n) ) return; if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam n = n + 1; } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 51ab00073a..a7a7c9ea11 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -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'][15] = array( __('Edit'), 'edit_pages', 'edit-pages.php' ); -$menu[25] = array( sprintf( __('Comments %s'), "" . number_format_i18n($awaiting_mod) . "" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' ); +$menu[25] = array( sprintf( __('Comments %s'), "" . number_format_i18n($awaiting_mod) . "" ), '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 diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 41218cb59b..f4aa49f083 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -156,7 +156,7 @@ function wp_default_scripts( &$scripts ) { 'good' => __('Medium'), '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( 'pending' => __('%i% pending'), // must look like: "# blah blah" 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),