WordPress.org

Make WordPress Core

Changeset 9241


Ignore:
Timestamp:
10/18/08 17:00:20 (6 years ago)
Author:
azaozz
Message:

Comments post-box: show 10 comments at load only if the postbox is not hidden

Location:
trunk
Files:
3 edited

Legend:

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

    r9233 r9241  
    341341</p> 
    342342<?php 
    343  
    344     if ( !$post_ID || $post_ID < 0 || 0 == $post->comment_count ) 
     343    $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)); 
     344 
     345    if ( !$post_ID || $post_ID < 0 || 1 > $total ) 
    345346        return; 
    346347 
     
    359360</tbody> 
    360361</table> 
    361 <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> 
    362 <?php 
     362<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> 
     363<?php 
     364    $hidden = (array) get_user_option( "meta-box-hidden_post" ); 
     365    if ( ! in_array('commentstatusdiv', $hidden) ) { ?> 
     366        <script type="text/javascript">commentsBox.get(<?php echo $total; ?>, 10);</script> 
     367<?php 
     368    } 
    363369} 
    364370add_meta_box('commentstatusdiv', __('Comments on this Post'), 'post_comment_status_meta_box', 'post', 'normal', 'core'); 
  • trunk/wp-admin/js/post.js

    r9225 r9241  
    235235        st : 0, 
    236236 
    237         get : function(id, nonce) { 
     237        get : function(total, num) { 
    238238            var st = this.st; 
    239             this.st += 20; 
    240  
     239            if ( ! num ) 
     240                num = 20; 
     241 
     242            this.st += num; 
     243            this.total = total; 
    241244            $('.waiting').show(); 
    242245 
     
    247250                'post_ID' : $('#post_ID').val(), 
    248251                'start' : st, 
    249                 'num' : '20' 
     252                'num' : num 
    250253            }; 
    251254 
     
    263266                        $("a[className*=':']").unbind(); 
    264267                        setCommentsList(); 
    265                         $('#show-comments').html(postL10n.showcomm); 
     268 
     269                        if ( commentsBox.st > commentsBox.total ) 
     270                            $('#show-comments').hide(); 
     271                        else 
     272                            $('#show-comments').html(postL10n.showcomm); 
    266273                        return; 
    267274                    } else if ( 1 == r ) { 
  • trunk/wp-includes/script-loader.php

    r9240 r9241  
    176176            'cancel' => __('Cancel'), 
    177177        ) ); 
    178         $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug', 'settings-box'), '20080925' ); 
     178        $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug', 'settings-box'), '20081018' ); 
    179179        $scripts->localize( 'post', 'postL10n', array( 
    180180            'tagsUsed' =>  __('Tags used on this post:'), 
Note: See TracChangeset for help on using the changeset viewer.