- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r33468 r34170 348 348 349 349 // 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 } 352 366 353 367 $total += $delta; … … 358 372 if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { 359 373 $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'; 361 376 $parsed = parse_url( $url ); 362 377 if ( isset( $parsed['query'] ) ) { … … 378 393 // The time since the last comment count. 379 394 $time = time(); 395 $comment = get_comment( $comment_id ); 380 396 381 397 $x = new WP_Ajax_Response( array( … … 384 400 'id' => $comment_id, 385 401 'supplemental' => array( 402 'status' => $comment ? $comment->comment_approved : '', 403 'postId' => $comment ? $comment->comment_post_ID : '', 386 404 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 387 405 'total_pages' => ceil( $total / $per_page ), … … 504 522 505 523 check_ajax_referer( "delete-comment_$id" ); 506 $status = wp_get_comment_status( $comment ->comment_ID);524 $status = wp_get_comment_status( $comment ); 507 525 508 526 $delta = -1; … … 510 528 if ( 'trash' == $status ) 511 529 wp_die( time() ); 512 $r = wp_trash_comment( $comment ->comment_ID);530 $r = wp_trash_comment( $comment ); 513 531 } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) { 514 532 if ( 'trash' != $status ) 515 533 wp_die( time() ); 516 $r = wp_untrash_comment( $comment ->comment_ID);534 $r = wp_untrash_comment( $comment ); 517 535 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash 518 536 $delta = 1; … … 520 538 if ( 'spam' == $status ) 521 539 wp_die( time() ); 522 $r = wp_spam_comment( $comment ->comment_ID);540 $r = wp_spam_comment( $comment ); 523 541 } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) { 524 542 if ( 'spam' != $status ) 525 543 wp_die( time() ); 526 $r = wp_unspam_comment( $comment ->comment_ID);544 $r = wp_unspam_comment( $comment ); 527 545 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam 528 546 $delta = 1; 529 547 } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { 530 $r = wp_delete_comment( $comment ->comment_ID);548 $r = wp_delete_comment( $comment ); 531 549 } else { 532 550 wp_die( -1 ); … … 714 732 wp_die( -1 ); 715 733 716 $current = wp_get_comment_status( $comment ->comment_ID);734 $current = wp_get_comment_status( $comment ); 717 735 if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) 718 736 wp_die( time() ); 719 737 720 738 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 } 725 744 726 745 if ( is_wp_error($result) ) { … … 995 1014 996 1015 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' ) ) 998 1021 $comment_auto_approved = true; 999 1022 } … … 1028 1051 1029 1052 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 ); 1031 1054 1032 1055 $x = new WP_Ajax_Response(); … … 1178 1201 // If the post is an autodraft, save the post as a draft and then attempt to save the meta. 1179 1202 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'; 1186 1208 $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 ) { 1190 1213 if ( is_wp_error( $pid ) ) { 1191 1214 $x = new WP_Ajax_Response( array( … … 1195 1218 $x->send(); 1196 1219 } 1197 $_POST = $save_POST; // Now we can restore original $_POST again 1220 1198 1221 if ( !$mid = add_meta( $pid ) ) 1199 1222 wp_die( __( 'Please provide a custom field value.' ) ); … … 1505 1528 check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); 1506 1529 $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 ) ); 1508 1531 } 1509 1532 … … 1893 1916 'success' => false, 1894 1917 'data' => array( 1895 'message' => __( "You don't have permission to upload files."),1918 'message' => __( 'You do not have permission to upload files.' ), 1896 1919 'filename' => $_FILES['async-upload']['name'], 1897 1920 ) … … 3133 3156 $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. 3134 3157 3135 $parent_url = get_post( $attachment_id )->guid;3158 $parent_url = wp_get_attachment_url( $attachment_id ); 3136 3159 $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); 3137 3160
Note: See TracChangeset
for help on using the changeset viewer.