wp_count_comments example

$post_type_object = get_post_type_object( $post_type );

            if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
                printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type$text );
            } else {
                printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type$text );
            }
        }
    }

    // Comments.     $num_comm = wp_count_comments();

    if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
        /* translators: %s: Number of comments. */
        $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved )number_format_i18n( $num_comm->approved ) );
        ?> <li class="comment-count"> <a href="edit-comments.php"><?php echo $text; ?></a> </li> <?php         $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
        /* translators: %s: Number of comments. */
        
if ( empty( $post['ID'] ) ) {
            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
        }

        if ( ! current_user_can( 'edit_post', $post_id ) ) {
            return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) );
        }

        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
        do_action( 'xmlrpc_call', 'wp.getCommentCount', $args$this );

        $count = wp_count_comments( $post_id );

        return array(
            'approved'            => $count->approved,
            'awaiting_moderation' => $count->moderated,
            'spam'                => $count->spam,
            'total_comments'      => $count->total_comments,
        );
    }

    /** * Retrieves post statuses. * * @since 2.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $0 Blog ID (unused). * @type string $1 Username. * @type string $2 Password. * } * @return array|IXR_Error */

function wp_admin_bar_comments_menu( $wp_admin_bar ) {
    if ( ! current_user_can( 'edit_posts' ) ) {
        return;
    }

    $awaiting_mod  = wp_count_comments();
    $awaiting_mod  = $awaiting_mod->moderated;
    $awaiting_text = sprintf(
        /* translators: Hidden accessibility text. %s: Number of comments. */
        _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
        number_format_i18n( $awaiting_mod )
    );

    $icon   = '<span class="ab-icon" aria-hidden="true"></span>';
    $title  = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
    $title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';

    
$menu[15]                           = array( __( 'Links' ), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' );
    $submenu['link-manager.php'][5] = array( _x( 'All Links', 'admin menu' ), 'manage_links', 'link-manager.php' );
    /* translators: Add new links. */
    $submenu['link-manager.php'][10] = array( _x( 'Add New', 'link' ), 'manage_links', 'link-add.php' );
    $submenu['link-manager.php'][15] = array( __( 'Link Categories' ), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );

// $menu[20] = Pages.
// Avoid the comment count query for users who cannot edit_posts. if ( current_user_can( 'edit_posts' ) ) {
    $awaiting_mod      = wp_count_comments();
    $awaiting_mod      = $awaiting_mod->moderated;
    $awaiting_mod_i18n = number_format_i18n( $awaiting_mod );
    /* translators: %s: Number of comments. */
    $awaiting_mod_text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod )$awaiting_mod_i18n );

    $menu[25] = array(
        /* translators: %s: Number of comments. */
        sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count" aria-hidden="true">' . $awaiting_mod_i18n . '</span><span class="comments-in-moderation-text screen-reader-text">' . $awaiting_mod_text . '</span></span>' ),
        'edit_posts',
        'edit-comments.php',
        '',
        


    /** * @global int $post_id * @global string $comment_status * @global string $comment_type */
    protected function get_views() {
        global $post_id$comment_status$comment_type;

        $status_links = array();
        $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();

        $stati = array(
            /* translators: %s: Number of comments. */
            'all'       => _nx_noop(
                'All <span class="count">(%s)</span>',
                'All <span class="count">(%s)</span>',
                'comments'
            ), // Singular not used.
            /* translators: %s: Number of comments. */
            'mine'      => _nx_noop(
                
public static function check_for_spam_button( $comment_status ) {
        // The "Check for Spam" button should only appear when the page might be showing         // a comment with comment_approved=0, which means an un-trashed, un-spammed,         // not-yet-moderated comment.         if ( 'all' != $comment_status && 'moderated' != $comment_status ) {
            return;
        }

        $link = '';

        $comments_count = wp_count_comments();
        
        echo '</div>';
        echo '<div class="alignleft actions">';

        $classes = array(
            'button-secondary',
            'checkforspam',
            'button-disabled'    // Disable button until the page is loaded         );

        if ( $comments_count->moderated > 0 ) {
            
$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();

        $x = new WP_Ajax_Response(
            array(
                'what'         => 'comment',
                // Here for completeness - not used.                 'id'           => $comment_id,
                'supplemental' => array(
                    'status'               => $comment_status,
                    'postId'               => $comment ? $comment->comment_post_ID : '',
                    'time'                 => $time,
                    'in_moderation'        => $counts->moderated,
                    
$wp_list_table->prepare_items();

wp_enqueue_script( 'admin-comments' );
enqueue_comment_hotkeys_js();

/** * @global int $post_id */
global $post_id;

if ( $post_id ) {
    $comments_count      = wp_count_comments( $post_id );
    $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '&hellip;' );

    if ( $comments_count->moderated > 0 ) {
        // Used in the HTML title tag.         $title = sprintf(
            /* translators: 1: Comments count, 2: Post title. */
            __( 'Comments (%1$s) on &#8220;%2$s&#8221;' ),
            number_format_i18n( $comments_count->moderated ),
            $draft_or_post_title
        );
    } else {
        
Home | Imprint | This part of the site doesn't use cookies.