Make WordPress Core


Ignore:
Timestamp:
02/02/2009 03:41:19 AM (16 years ago)
Author:
azaozz
Message:

Show comments on the Edit Post screen in separate postbox

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r10458 r10480  
    1212 * @var int
    1313 */
    14 if ( ! isset( $post_ID ) )
    15     $post_ID = 0;
    16 else
    17     $post_ID = (int) $post_ID;
     14$post_ID = isset($post_ID) ? (int) $post_ID : 0;
    1815
    1916$action = isset($action) ? $action : '';
     
    438435 */
    439436function post_comment_status_meta_box($post) {
    440     global $wpdb, $post_ID;
    441437?>
    442438<input name="advanced_view" type="hidden" value="1" />
     
    446442</p>
    447443<?php
     444}
     445add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
     446
     447/**
     448 * Display comments for post.
     449 *
     450 * @since 2.8.0
     451 *
     452 * @param object $post
     453 */
     454function post_comment_meta_box($post) {
     455    global $wpdb, $post_ID;
     456
    448457    $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));
    449458
    450     if ( !$post_ID || $post_ID < 0 || 1 > $total )
     459    if ( 1 > $total ) {
     460        echo '<p>' . __('No comments yet.') . '</p>';
    451461        return;
    452 
    453 wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
     462    }
     463
     464    wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
    454465?>
    455466
     
    467478<?php
    468479    $hidden = get_hidden_meta_boxes('post');
    469     if ( ! in_array('commentstatusdiv', $hidden) ) { ?>
     480    if ( ! in_array('commentsdiv', $hidden) ) { ?>
    470481        <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
    471482<?php
    472483    }
    473484}
    474 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
     485if ( 'publish' == $post->post_status || 'private' == $post->post_status )
     486    add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');
    475487
    476488/**
Note: See TracChangeset for help on using the changeset viewer.