Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-admin/admin-ajax.php

    r18110 r18018  
    509509    break;
    510510case 'add-tag' :
    511     check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
     511    check_ajax_referer( 'add-tag' );
    512512    $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
    513513    $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
     
    610610        die('1');
    611611
     612    $comment_list_item = '';
    612613    $x = new WP_Ajax_Response();
    613     ob_start();
    614614    foreach ( $wp_list_table->items as $comment ) {
    615615        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    }
    621621    $x->add( array(
    622622        'what' => 'comments',
     
    661661
    662662    $comment_parent = absint($_POST['comment_ID']);
    663     $comment_auto_approved = false;
    664663    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    665664
     
    668667    if ( ! $comment ) die('1');
    669668
    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();
    682672
    683673    ob_start();
     
    696686    ob_end_clean();
    697687
    698     $response = array(
     688    $x->add( array(
    699689        'what' => 'comment',
    700690        'id' => $comment->comment_ID,
    701691        'data' => $comment_list_item,
    702692        '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
    710695    $x->send();
    711696    break;
     
    860845        ) );
    861846    } else { // Update?
    862         $mid = (int) array_pop( array_keys($_POST['meta']) );
     847        $mid = (int) array_pop( $var_by_ref = array_keys($_POST['meta']) );
    863848        $key = $_POST['meta'][$mid]['key'];
    864849        $value = $_POST['meta'][$mid]['value'];
     
    934919    $do_lock = true;
    935920
    936     $data = $alert = '';
     921    $data = '';
    937922    /* translators: draft saved date format, see http://php.net/date */
    938923    $draft_saved_date_format = __('g:i:s a');
     
    942927    $supplemental = array();
    943928    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() );
    945930
    946931    $id = $revision_id = 0;
     
    957942        $last_user = get_userdata( $last );
    958943        $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        ) );
    960948
    961949        $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 ) );
    963950    }
    964951
     
    1005992        }
    1006993    }
    1007 
    1008     if ( ! empty($alert) )
    1009         $supplemental['alert'] = $alert;
    1010994
    1011995    $x = new WP_Ajax_Response( array(
     
    14861470    die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
    14871471    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;
    15501472default :
    15511473    do_action( 'wp_ajax_' . $_POST['action'] );
Note: See TracChangeset for help on using the changeset viewer.