Make WordPress Core


Ignore:
Timestamp:
08/31/2015 05:57:32 PM (11 years ago)
Author:
wonderboymusic
Message:

Comments: dynamically update the document title text of the Comments List Table page when dynamically updating the number of comments awaiting moderation.

Fixes #33414.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-comments.php

    r33589 r33821  
    105105enqueue_comment_hotkeys_js();
    106106
    107 if ( $post_id )
    108         $title = sprintf( __( 'Comments on “%s”' ), wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) );
    109 else
    110         $title = __('Comments');
     107if ( $post_id ) {
     108        $comments_count = wp_count_comments( $post_id );
     109        $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' );
     110        if ( $comments_count->moderated > 0 ) {
     111                $title = sprintf(
     112                        __( 'Comments (%s) on “%s”' ),
     113                        number_format_i18n( $comments_count->moderated ),
     114                        $draft_or_post_title
     115                );
     116        } else {
     117                $title = sprintf( __( 'Comments on “%s”' ), $draft_or_post_title );
     118        }
     119} else {
     120        $comments_count = wp_count_comments();
     121        if ( $comments_count->moderated > 0 ) {
     122                $title = sprintf(
     123                        __( 'Comments (%s)' ),
     124                        number_format_i18n( $comments_count->moderated )
     125                );
     126        } else {
     127                $title = __( 'Comments' );
     128        }
     129}
    111130
    112131add_screen_option( 'per_page' );
Note: See TracChangeset for help on using the changeset viewer.