Show comments on the Edit Post screen in separate postbox

git-svn-id: http://svn.automattic.com/wordpress/trunk@10480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-02-02 03:41:19 +00:00
parent fc511373de
commit 12676c8e03
5 changed files with 40 additions and 16 deletions

View File

@ -11,10 +11,7 @@
* @name $post_ID
* @var int
*/
if ( ! isset( $post_ID ) )
$post_ID = 0;
else
$post_ID = (int) $post_ID;
$post_ID = isset($post_ID) ? (int) $post_ID : 0;
$action = isset($action) ? $action : '';
if ( isset($_GET['message']) )
@ -437,7 +434,6 @@ do_action('dbx_post_advanced');
* @param object $post
*/
function post_comment_status_meta_box($post) {
global $wpdb, $post_ID;
?>
<input name="advanced_view" type="hidden" value="1" />
<p class="meta-options">
@ -445,12 +441,27 @@ function post_comment_status_meta_box($post) {
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a> on this post') ?></label>
</p>
<?php
}
add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
/**
* 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 ( !$post_ID || $post_ID < 0 || 1 > $total )
if ( 1 > $total ) {
echo '<p>' . __('No comments yet.') . '</p>';
return;
}
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
?>
<table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
@ -466,12 +477,13 @@ wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
<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="images/loading.gif" alt="" /></p>
<?php
$hidden = get_hidden_meta_boxes('post');
if ( ! in_array('commentstatusdiv', $hidden) ) { ?>
if ( ! in_array('commentsdiv', $hidden) ) { ?>
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<?php
}
}
add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
if ( 'publish' == $post->post_status || 'private' == $post->post_status )
add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');
/**
* Display post slug form fields.

View File

@ -133,7 +133,7 @@ var commentsBox, tagCloud;
this.st += num;
this.total = total;
$('.waiting').show();
$('#commentsdiv img.waiting').show();
data = {
'action' : 'get-comments',
@ -147,8 +147,8 @@ var commentsBox, tagCloud;
$.post(ajaxurl, data,
function(r) {
r = wpAjax.parseAjaxResponse(r);
$('#commentstatusdiv .widefat').show();
$('.waiting').hide();
$('#commentsdiv .widefat').show();
$('#commentsdiv img.waiting').hide();
if ( 'object' == typeof r && r.responses[0] ) {
$('#the-comment-list').append( r.responses[0].data );

File diff suppressed because one or more lines are too long

View File

@ -1364,8 +1364,20 @@ table.form-table td .updated {
}
#side-sortables .comments-box,
#side-sortables #show-comments {
display: none;
#normal-sortables .comments-box {
border: 0 none;
}
#side-sortables .comments-box thead th,
#normal-sortables .comments-box thead th {
background: transparent;
padding: 0 7px 4px;
font-style: italic;
}
#commentsdiv img.waiting {
padding-left: 5px;
vertical-align: middle;
}
#post-body .tagsdiv #newtag {

View File

@ -249,7 +249,7 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};'
) );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20090117' );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20090201' );
$scripts->add_data( 'post', 'group', 1 );
$scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'),