Comments post-box: show 10 comments at load only if the postbox is not hidden
git-svn-id: http://svn.automattic.com/wordpress/trunk@9241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e6a11a4232
commit
a8f998d914
|
@ -340,8 +340,9 @@ function post_comment_status_meta_box($post) {
|
|||
<label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments on this post') ?></label>
|
||||
</p>
|
||||
<?php
|
||||
$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 || 0 == $post->comment_count )
|
||||
if ( !$post_ID || $post_ID < 0 || 1 > $total )
|
||||
return;
|
||||
|
||||
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
|
||||
|
@ -358,8 +359,13 @@ wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
|
|||
<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();return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /></p>
|
||||
<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 = (array) get_user_option( "meta-box-hidden_post" );
|
||||
if ( ! in_array('commentstatusdiv', $hidden) ) { ?>
|
||||
<script type="text/javascript">commentsBox.get(<?php echo $total; ?>, 10);</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_meta_box('commentstatusdiv', __('Comments on this Post'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
|
||||
|
||||
|
|
|
@ -234,10 +234,13 @@ jQuery(document).ready( function($) {
|
|||
commentsBox = {
|
||||
st : 0,
|
||||
|
||||
get : function(id, nonce) {
|
||||
get : function(total, num) {
|
||||
var st = this.st;
|
||||
this.st += 20;
|
||||
if ( ! num )
|
||||
num = 20;
|
||||
|
||||
this.st += num;
|
||||
this.total = total;
|
||||
$('.waiting').show();
|
||||
|
||||
var data = {
|
||||
|
@ -246,7 +249,7 @@ jQuery(document).ready( function($) {
|
|||
'_ajax_nonce' : $('#add_comment_nonce').val(),
|
||||
'post_ID' : $('#post_ID').val(),
|
||||
'start' : st,
|
||||
'num' : '20'
|
||||
'num' : num
|
||||
};
|
||||
|
||||
$.post('admin-ajax.php', data,
|
||||
|
@ -262,7 +265,11 @@ jQuery(document).ready( function($) {
|
|||
theList = theExtraList = null;
|
||||
$("a[className*=':']").unbind();
|
||||
setCommentsList();
|
||||
$('#show-comments').html(postL10n.showcomm);
|
||||
|
||||
if ( commentsBox.st > commentsBox.total )
|
||||
$('#show-comments').hide();
|
||||
else
|
||||
$('#show-comments').html(postL10n.showcomm);
|
||||
return;
|
||||
} else if ( 1 == r ) {
|
||||
$('#show-comments').parent().html(postL10n.endcomm);
|
||||
|
|
|
@ -175,7 +175,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
'save' => __('Save'),
|
||||
'cancel' => __('Cancel'),
|
||||
) );
|
||||
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug', 'settings-box'), '20080925' );
|
||||
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug', 'settings-box'), '20081018' );
|
||||
$scripts->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
'add' => attribute_escape(__('Add')),
|
||||
|
|
Loading…
Reference in New Issue