Make WordPress Core


Ignore:
Timestamp:
03/09/2012 01:30:11 AM (15 years ago)
Author:
azaozz
Message:

Add new comment from post edit screen, partial props: garyc40, see #15527

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/meta-boxes.php

    r20077 r20164  
    472472        global $wpdb, $post_ID;
    473473
     474        wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
     475        ?>
     476        <p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post_ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
     477        <?php
     478
    474479        $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));
    475 
    476         if ( 1 > $total ) {
    477                 echo '<p>' . __('No comments yet.') . '</p>';
    478                 return;
    479         }
    480 
    481         wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
    482 
    483480        $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
    484481        $wp_list_table->display( true );
    485 ?>
    486 <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>
    487 <?php
    488         $hidden = get_hidden_meta_boxes('post');
    489         if ( ! in_array('commentsdiv', $hidden) ) { ?>
    490                 <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
    491 <?php
     482
     483        if ( 1 > $total ) {
     484                echo '<p id="no-comments">' . __('No comments yet.') . '</p>';
     485        } else {
     486                $hidden = get_hidden_meta_boxes('post');
     487                if ( ! in_array('commentsdiv', $hidden) ) {
     488                        ?>
     489                        <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
     490                        <?php
     491                }
    492492        }
     493
     494        ?>
     495        <p class="hide-if-no-js hidden" id="show-comments"><a href="#commentstatusdiv" 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>
     496        <?php
     497
    493498        wp_comment_trashnotice();
    494499}
Note: See TracChangeset for help on using the changeset viewer.