get_pending_comments_num example


    public function column_comments( $post ) {
        echo '<div class="post-com-count-wrapper">';

        if ( isset( $this->comment_pending_count[ $post->ID ] ) ) {
            $pending_comments = $this->comment_pending_count[ $post->ID ];
        } else {
            $pending_comments = get_pending_comments_num( $post->ID );
        }

        $this->comments_bubble( $post->ID, $pending_comments );

        echo '</div>';
    }

    /** * Handles output for the default column. * * @since 4.3.0 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. * * @param WP_Post $item The current WP_Post object. * @param string $column_name Current column name. */

        $args = apply_filters( 'comments_list_table_query_args', $args );

        $_comments = get_comments( $args );

        if ( is_array( $_comments ) ) {
            $this->items       = array_slice( $_comments, 0, $comments_per_page );
            $this->extra_items = array_slice( $_comments$comments_per_page );

            $_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) );

            $this->pending_count = get_pending_comments_num( $_comment_post_ids );
        }

        $total_comments = get_comments(
            array_merge(
                $args,
                array(
                    'count'  => true,
                    'offset' => 0,
                    'number' => 0,
                )
            )
        );
private function _display_rows( $posts$level = 0 ) {
        $post_type = $this->screen->post_type;

        // Create array of post IDs.         $post_ids = array();

        foreach ( $posts as $a_post ) {
            $post_ids[] = $a_post->ID;
        }

        if ( post_type_supports( $post_type, 'comments' ) ) {
            $this->comment_pending_count = get_pending_comments_num( $post_ids );
        }
        update_post_author_caches( $posts );

        foreach ( $posts as $post ) {
            $this->single_row( $post$level );
        }
    }

    /** * @global wpdb $wpdb WordPress database abstraction object. * @global WP_Post $post Global post object. * @param array $pages * @param int $pagenum * @param int $per_page */
Home | Imprint | This part of the site doesn't use cookies.