Make WordPress Core


Ignore:
Timestamp:
03/27/2007 09:20:16 PM (20 years ago)
Author:
ryan
Message:

Dynamically refill comment list when a comment is deleted. Props mdawaffe. fixes #4038

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r5089 r5118  
    150150                'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name))
    151151        ) );
     152        $x->send();
     153        break;
     154case 'add-comment' :
     155        if ( !current_user_can( 'edit_post', $id ) )
     156                die('-1');
     157        $search = isset($_POST['s']) ? $_POST['s'] : false;
     158        $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25;
     159
     160        list($comments, $total) = _wp_get_comment_list( $search, $start, 1 );
     161
     162        if ( !$comments )
     163                die('1');
     164        $x = new WP_Ajax_Response();
     165        foreach ( (array) $comments as $comment ) {
     166                get_comment( $comment );
     167                ob_start();
     168                        _wp_comment_list_item( $comment->comment_ID );
     169                        $comment_list_item = ob_get_contents();
     170                ob_end_clean();
     171                $x->add( array(
     172                        'what' => 'comment',
     173                        'id' => $comment->comment_ID,
     174                        'data' => $comment_list_item
     175                ) );
     176        }
    152177        $x->send();
    153178        break;
Note: See TracChangeset for help on using the changeset viewer.