Changes from trunk/wp-admin/admin-ajax.php at r18110 to branches/3.1/wp-admin/admin-ajax.php at r18018
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-admin/admin-ajax.php
r18110 r18018 509 509 break; 510 510 case 'add-tag' : 511 check_ajax_referer( 'add-tag' , '_wpnonce_add-tag');511 check_ajax_referer( 'add-tag' ); 512 512 $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post'; 513 513 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; … … 610 610 die('1'); 611 611 612 $comment_list_item = ''; 612 613 $x = new WP_Ajax_Response(); 613 ob_start();614 614 foreach ( $wp_list_table->items as $comment ) { 615 615 get_comment( $comment ); 616 $wp_list_table->single_row( $comment);617 }618 $comment_list_item= ob_get_contents();619 ob_end_clean();620 616 ob_start(); 617 $wp_list_table->single_row( $comment ); 618 $comment_list_item .= ob_get_contents(); 619 ob_end_clean(); 620 } 621 621 $x->add( array( 622 622 'what' => 'comments', … … 661 661 662 662 $comment_parent = absint($_POST['comment_ID']); 663 $comment_auto_approved = false;664 663 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); 665 664 … … 668 667 if ( ! $comment ) die('1'); 669 668 670 $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; 671 672 673 // automatically approve parent comment 674 if ( !empty($_POST['approve_parent']) ) { 675 $parent = get_comment( $comment_parent ); 676 677 if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) { 678 if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) ) 679 $comment_auto_approved = true; 680 } 681 } 669 $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; 670 671 $x = new WP_Ajax_Response(); 682 672 683 673 ob_start(); … … 696 686 ob_end_clean(); 697 687 698 $ response =array(688 $x->add( array( 699 689 'what' => 'comment', 700 690 'id' => $comment->comment_ID, 701 691 'data' => $comment_list_item, 702 692 'position' => $position 703 ); 704 705 if ( $comment_auto_approved ) 706 $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID ); 707 708 $x = new WP_Ajax_Response(); 709 $x->add( $response ); 693 )); 694 710 695 $x->send(); 711 696 break; … … 860 845 ) ); 861 846 } else { // Update? 862 $mid = (int) array_pop( array_keys($_POST['meta']) );847 $mid = (int) array_pop( $var_by_ref = array_keys($_POST['meta']) ); 863 848 $key = $_POST['meta'][$mid]['key']; 864 849 $value = $_POST['meta'][$mid]['value']; … … 934 919 $do_lock = true; 935 920 936 $data = $alert ='';921 $data = ''; 937 922 /* translators: draft saved date format, see http://php.net/date */ 938 923 $draft_saved_date_format = __('g:i:s a'); … … 942 927 $supplemental = array(); 943 928 if ( isset($login_grace_period) ) 944 $ alert .= sprintf( __('Your login has expired. Please open a new browser window and <a href="%s" target="_blank">log in again</a>. '), add_query_arg( 'interim-login', 1, wp_login_url()) );929 $supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() ); 945 930 946 931 $id = $revision_id = 0; … … 957 942 $last_user = get_userdata( $last ); 958 943 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); 959 $data = __( 'Autosave disabled.' ); 944 $data = new WP_Error( 'locked', sprintf( 945 $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), 946 esc_html( $last_user_name ) 947 ) ); 960 948 961 949 $supplemental['disable_autosave'] = 'disable'; 962 $alert .= sprintf( __( '%s is currently editing this article. If you update it, you will overwrite the changes.' ), esc_html( $last_user_name ) );963 950 } 964 951 … … 1005 992 } 1006 993 } 1007 1008 if ( ! empty($alert) )1009 $supplemental['alert'] = $alert;1010 994 1011 995 $x = new WP_Ajax_Response( array( … … 1486 1470 die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) ); 1487 1471 break; 1488 case 'wp-fullscreen-save-post' :1489 if ( isset($_POST['post_ID']) )1490 $post_id = (int) $_POST['post_ID'];1491 else1492 $post_id = 0;1493 1494 $post = null;1495 $post_type_object = null;1496 $post_type = null;1497 if ( $post_id ) {1498 $post = get_post($post_id);1499 if ( $post ) {1500 $post_type_object = get_post_type_object($post->post_type);1501 if ( $post_type_object ) {1502 $post_type = $post->post_type;1503 $current_screen->post_type = $post->post_type;1504 $current_screen->id = $current_screen->post_type;1505 }1506 }1507 } elseif ( isset($_POST['post_type']) ) {1508 $post_type_object = get_post_type_object($_POST['post_type']);1509 if ( $post_type_object ) {1510 $post_type = $post_type_object->name;1511 $current_screen->post_type = $post_type;1512 $current_screen->id = $current_screen->post_type;1513 }1514 }1515 1516 check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');1517 1518 $post_id = edit_post();1519 1520 if ( is_wp_error($post_id) ) {1521 if ( $post_id->get_error_message() )1522 $message = $post_id->get_error_message();1523 else1524 $message = __('Save failed');1525 1526 echo json_encode( array( 'message' => $message, 'last_edited' => '' ) );1527 die();1528 } else {1529 $message = __('Saved.');1530 }1531 1532 if ( $post ) {1533 $last_date = mysql2date( get_option('date_format'), $post->post_modified );1534 $last_time = mysql2date( get_option('time_format'), $post->post_modified );1535 } else {1536 $last_date = date_i18n( get_option('date_format') );1537 $last_time = date_i18n( get_option('time_format') );1538 }1539 1540 if ( $last_id = get_post_meta($post_id, '_edit_last', true) ) {1541 $last_user = get_userdata($last_id);1542 $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );1543 } else {1544 $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );1545 }1546 1547 echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );1548 die();1549 break;1550 1472 default : 1551 1473 do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset
for help on using the changeset viewer.