Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r33468 r34170  
    348348
    349349    // JS didn't send us everything we need to know. Just die with success message
    350     if ( !$total || !$per_page || !$page || !$url )
    351         wp_die( time() );
     350    if ( ! $total || ! $per_page || ! $page || ! $url ) {
     351        $time = time();
     352        $comment = get_comment( $comment_id );
     353
     354        $x = new WP_Ajax_Response( array(
     355            'what' => 'comment',
     356            // Here for completeness - not used.
     357            'id' => $comment_id,
     358            'supplemental' => array(
     359                'status' => $comment ? $comment->comment_approved : '',
     360                'postId' => $comment ? $comment->comment_post_ID : '',
     361                'time' => $time
     362            )
     363        ) );
     364        $x->send();
     365    }
    352366
    353367    $total += $delta;
     
    358372    if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
    359373        $post_id = 0;
    360         $status = 'total_comments'; // What type of comment count are we looking for?
     374        // What type of comment count are we looking for?
     375        $status = 'all';
    361376        $parsed = parse_url( $url );
    362377        if ( isset( $parsed['query'] ) ) {
     
    378393    // The time since the last comment count.
    379394    $time = time();
     395    $comment = get_comment( $comment_id );
    380396
    381397    $x = new WP_Ajax_Response( array(
     
    384400        'id' => $comment_id,
    385401        'supplemental' => array(
     402            'status' => $comment ? $comment->comment_approved : '',
     403            'postId' => $comment ? $comment->comment_post_ID : '',
    386404            'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
    387405            'total_pages' => ceil( $total / $per_page ),
     
    504522
    505523    check_ajax_referer( "delete-comment_$id" );
    506     $status = wp_get_comment_status( $comment->comment_ID );
     524    $status = wp_get_comment_status( $comment );
    507525
    508526    $delta = -1;
     
    510528        if ( 'trash' == $status )
    511529            wp_die( time() );
    512         $r = wp_trash_comment( $comment->comment_ID );
     530        $r = wp_trash_comment( $comment );
    513531    } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
    514532        if ( 'trash' != $status )
    515533            wp_die( time() );
    516         $r = wp_untrash_comment( $comment->comment_ID );
     534        $r = wp_untrash_comment( $comment );
    517535        if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
    518536            $delta = 1;
     
    520538        if ( 'spam' == $status )
    521539            wp_die( time() );
    522         $r = wp_spam_comment( $comment->comment_ID );
     540        $r = wp_spam_comment( $comment );
    523541    } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
    524542        if ( 'spam' != $status )
    525543            wp_die( time() );
    526         $r = wp_unspam_comment( $comment->comment_ID );
     544        $r = wp_unspam_comment( $comment );
    527545        if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
    528546            $delta = 1;
    529547    } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
    530         $r = wp_delete_comment( $comment->comment_ID );
     548        $r = wp_delete_comment( $comment );
    531549    } else {
    532550        wp_die( -1 );
     
    714732        wp_die( -1 );
    715733
    716     $current = wp_get_comment_status( $comment->comment_ID );
     734    $current = wp_get_comment_status( $comment );
    717735    if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
    718736        wp_die( time() );
    719737
    720738    check_ajax_referer( "approve-comment_$id" );
    721     if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
    722         $result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
    723     else
    724         $result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
     739    if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
     740        $result = wp_set_comment_status( $comment, 'approve', true );
     741    } else {
     742        $result = wp_set_comment_status( $comment, 'hold', true );
     743    }
    725744
    726745    if ( is_wp_error($result) ) {
     
    9951014
    9961015        if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
    997             if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
     1016            if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
     1017                wp_die( -1 );
     1018            }
     1019
     1020            if ( wp_set_comment_status( $parent, 'approve' ) )
    9981021                $comment_auto_approved = true;
    9991022        }
     
    10281051
    10291052    if ( $comment_auto_approved )
    1030         $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );
     1053        $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID );
    10311054
    10321055    $x = new WP_Ajax_Response();
     
    11781201        // If the post is an autodraft, save the post as a draft and then attempt to save the meta.
    11791202        if ( $post->post_status == 'auto-draft' ) {
    1180             $save_POST = $_POST; // Backup $_POST
    1181             $_POST = array(); // Make it empty for edit_post()
    1182             $_POST['action'] = 'draft'; // Warning fix
    1183             $_POST['post_ID'] = $pid;
    1184             $_POST['post_type'] = $post->post_type;
    1185             $_POST['post_status'] = 'draft';
     1203            $post_data = array();
     1204            $post_data['action'] = 'draft'; // Warning fix
     1205            $post_data['post_ID'] = $pid;
     1206            $post_data['post_type'] = $post->post_type;
     1207            $post_data['post_status'] = 'draft';
    11861208            $now = current_time('timestamp', 1);
    1187             $_POST['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( get_option( 'date_format' ), $now ), date( get_option( 'time_format' ), $now ) );
    1188 
    1189             if ( $pid = edit_post() ) {
     1209            $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( get_option( 'date_format' ), $now ), date( get_option( 'time_format' ), $now ) );
     1210
     1211            $pid = edit_post( $post_data );
     1212            if ( $pid ) {
    11901213                if ( is_wp_error( $pid ) ) {
    11911214                    $x = new WP_Ajax_Response( array(
     
    11951218                    $x->send();
    11961219                }
    1197                 $_POST = $save_POST; // Now we can restore original $_POST again
     1220
    11981221                if ( !$mid = add_meta( $pid ) )
    11991222                    wp_die( __( 'Please provide a custom field value.' ) );
     
    15051528    check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
    15061529    $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
    1507     wp_die( add_query_arg( array( 'preview' => 'true' ), get_permalink( $post_id ) ) );
     1530    wp_die( get_preview_post_link( $post_id ) );
    15081531}
    15091532
     
    18931916            'success' => false,
    18941917            'data'    => array(
    1895                 'message'  => __( "You don't have permission to upload files." ),
     1918                'message'  => __( 'You do not have permission to upload files.' ),
    18961919                'filename' => $_FILES['async-upload']['name'],
    18971920            )
     
    31333156            $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
    31343157
    3135             $parent_url = get_post( $attachment_id )->guid;
     3158            $parent_url = wp_get_attachment_url( $attachment_id );
    31363159            $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
    31373160
Note: See TracChangeset for help on using the changeset viewer.