Changes from branches/3.1/wp-admin/admin-ajax.php at r18018 to trunk/wp-admin/admin-ajax.php at r18110
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r18018 r18110 509 509 break; 510 510 case 'add-tag' : 511 check_ajax_referer( 'add-tag' );511 check_ajax_referer( 'add-tag', '_wpnonce_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 = '';613 612 $x = new WP_Ajax_Response(); 613 ob_start(); 614 614 foreach ( $wp_list_table->items as $comment ) { 615 615 get_comment( $comment ); 616 ob_start();617 $wp_list_table->single_row( $comment );618 $comment_list_item .= ob_get_contents();619 620 } 616 $wp_list_table->single_row( $comment ); 617 } 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; 663 664 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); 664 665 … … 667 668 if ( ! $comment ) die('1'); 668 669 669 $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; 670 671 $x = new WP_Ajax_Response(); 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 } 672 682 673 683 ob_start(); … … 686 696 ob_end_clean(); 687 697 688 $ x->add(array(698 $response = array( 689 699 'what' => 'comment', 690 700 'id' => $comment->comment_ID, 691 701 'data' => $comment_list_item, 692 702 'position' => $position 693 )); 694 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 ); 695 710 $x->send(); 696 711 break; … … 845 860 ) ); 846 861 } else { // Update? 847 $mid = (int) array_pop( $var_by_ref =array_keys($_POST['meta']) );862 $mid = (int) array_pop( array_keys($_POST['meta']) ); 848 863 $key = $_POST['meta'][$mid]['key']; 849 864 $value = $_POST['meta'][$mid]['value']; … … 919 934 $do_lock = true; 920 935 921 $data = '';936 $data = $alert = ''; 922 937 /* translators: draft saved date format, see http://php.net/date */ 923 938 $draft_saved_date_format = __('g:i:s a'); … … 927 942 $supplemental = array(); 928 943 if ( isset($login_grace_period) ) 929 $ supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );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() ) ); 930 945 931 946 $id = $revision_id = 0; … … 942 957 $last_user = get_userdata( $last ); 943 958 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); 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 ) ); 959 $data = __( 'Autosave disabled.' ); 948 960 949 961 $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 ) ); 950 963 } 951 964 … … 992 1005 } 993 1006 } 1007 1008 if ( ! empty($alert) ) 1009 $supplemental['alert'] = $alert; 994 1010 995 1011 $x = new WP_Ajax_Response( array( … … 1470 1486 die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) ); 1471 1487 break; 1488 case 'wp-fullscreen-save-post' : 1489 if ( isset($_POST['post_ID']) ) 1490 $post_id = (int) $_POST['post_ID']; 1491 else 1492 $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 else 1524 $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; 1472 1550 default : 1473 1551 do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset
for help on using the changeset viewer.