Пример #1
0
/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    global $wpdb, $post_ID;
    $total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM {$wpdb->comments} WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
    if (1 > $total) {
        echo '<p>' . __('No comments yet.') . '</p>';
        return;
    }
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    add_filter('manage_edit-comments_columns', 'post_comment_meta_box_thead', 8, 1);
    add_filter('manage_edit-comments_sortable_columns', create_function('', 'return array();'), 8);
    require_once './includes/default-list-tables.php';
    $wp_list_table = new WP_Comments_Table();
    ?>

<table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
<thead><tr>
	<?php 
    $wp_list_table->print_column_headers();
    ?>
</tr></thead>
<tbody id="the-comment-list" class="list:comment"></tbody>
</table>
<p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php 
    echo $total;
    ?>
);return false;"><?php 
    _e('Show comments');
    ?>
</a> <img class="waiting" style="display:none;" src="<?php 
    echo esc_url(admin_url('images/wpspin_light.gif'));
    ?>
" alt="" /></p>
<?php 
    $hidden = get_hidden_meta_boxes('post');
    if (!in_array('commentsdiv', $hidden)) {
        ?>
		<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
        echo $total;
        ?>
, 10);});</script>
<?php 
    }
    remove_filter('manage_edit-comments_columns', 'post_comment_meta_box_thead');
    wp_comment_trashnotice();
}