WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/07/2011 04:56:00 AM (10 years ago)
Author:
azaozz
Message:

Change comment Reply to Approve and Reply and auto-approve the comment if it is in moderation, props DH-Shredder, fixes #15898

File:
1 edited

Legend:

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

    r17831 r17832  
    667667    if ( ! $comment ) die('1');
    668668
    669     $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
    670 
    671     $x = new WP_Ajax_Response();
     669    $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
    672670
    673671    ob_start();
     
    686684    ob_end_clean();
    687685
    688     $x->add( array(
     686    $response = array(
    689687        'what' => 'comment',
    690688        'id' => $comment->comment_ID,
    691689        'data' => $comment_list_item,
    692690        'position' => $position
    693     ));
    694 
     691    );
     692
     693    // automatically approve parent comment
     694    if ( !empty($_POST['approve_parent']) ) {
     695        $parent = get_comment( $comment_parent );
     696
     697        if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
     698            if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
     699                $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );
     700        }
     701    }
     702
     703    $x = new WP_Ajax_Response();
     704    $x->add( $response );
    695705    $x->send();
    696706    break;
Note: See TracChangeset for help on using the changeset viewer.