Make WordPress Core

Changeset 19802


Ignore:
Timestamp:
01/31/2012 10:14:39 PM (15 years ago)
Author:
nacin
Message:

Use wp_die() in ajax-actions. props kurtpayne. see [19801], fixes #15327.

File:
1 edited

Legend:

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

    r19792 r19802  
    1515
    1616        if ( ! $id )
    17                 die('-1');
     17                wp_die( -1 );
    1818
    1919        $message = sprintf( __('<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="%s" target="_blank">Please log in again.</a>'), wp_login_url() );
     
    4242        $wp_list_table = _get_list_table( $list_class );
    4343        if ( ! $wp_list_table )
    44                 die( '0' );
     44                wp_die( 0 );
    4545
    4646        if ( ! $wp_list_table->ajax_user_can() )
    47                 die( '-1' );
     47                wp_die( -1 );
    4848
    4949        $wp_list_table->ajax_response();
    5050
    51         die( '0' );
     51        wp_die( 0 );
    5252}
    5353function wp_ajax_ajax_tag_search() {
     
    5858                $tax = get_taxonomy( $taxonomy );
    5959                if ( ! $tax )
    60                         die( '0' );
     60                        wp_die( 0 );
    6161                if ( ! current_user_can( $tax->cap->assign_terms ) )
    62                         die( '-1' );
     62                        wp_die( -1 );
    6363        } else {
    64                 die('0');
     64                wp_die( 0 );
    6565        }
    6666
     
    7373        $s = trim( $s );
    7474        if ( strlen( $s ) < 2 )
    75                 die; // require 2 chars for matching
     75                wp_die(); // require 2 chars for matching
    7676
    7777        $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
    7878
    7979        echo join( $results, "\n" );
    80         die;
     80        wp_die();
    8181}
    8282
    8383function wp_ajax_wp_compression_test() {
    8484        if ( !current_user_can( 'manage_options' ) )
    85                 die('-1');
     85                wp_die( -1 );
    8686
    8787        if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
    8888                update_site_option('can_compress_scripts', 0);
    89                 die('0');
     89                wp_die( 0 );
    9090        }
    9191
     
    101101                 if ( 1 == $_GET['test'] ) {
    102102                        echo $test_str;
    103                         die;
     103                        wp_die();
    104104                 } elseif ( 2 == $_GET['test'] ) {
    105105                        if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
    106                                 die('-1');
     106                                wp_die( -1 );
    107107                        if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    108108                                header('Content-Encoding: deflate');
     
    112112                                $out = gzencode( $test_str, 1 );
    113113                        } else {
    114                                 die('-1');
     114                                wp_die( -1 );
    115115                        }
    116116                        echo $out;
    117                         die;
     117                        wp_die();
    118118                } elseif ( 'no' == $_GET['test'] ) {
    119119                        update_site_option('can_compress_scripts', 0);
     
    123123        }
    124124
    125         die('0');
     125        wp_die( 0 );
    126126}
    127127
     
    129129        $post_id = intval($_GET['postid']);
    130130        if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
    131                 die('-1');
     131                wp_die( -1 );
    132132
    133133        check_ajax_referer( "image_editor-$post_id" );
     
    135135        include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
    136136        if ( ! stream_preview_image($post_id) )
    137                 die('-1');
    138 
    139         die();
     137                wp_die( -1 );
     138
     139        wp_die();
    140140}
    141141
     
    144144
    145145        $return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0';
    146         die( $return );
     146        wp_die( $return );
    147147}
    148148
     
    168168        // JS didn't send us everything we need to know. Just die with success message
    169169        if ( !$total || !$per_page || !$page || !$url )
    170                 die( (string) time() );
     170                wp_die( time() );
    171171
    172172        $total += $delta;
     
    218218        check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
    219219        if ( !current_user_can( $taxonomy->cap->edit_terms ) )
    220                 die('-1');
     220                wp_die( -1 );
    221221        $names = explode(',', $_POST['new'.$taxonomy->name]);
    222222        $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
     
    296296
    297297        if ( !$comment = get_comment( $id ) )
    298                 die( (string) time() );
     298                wp_die( time() );
    299299        if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
    300                 die('-1');
     300                wp_die( -1 );
    301301
    302302        check_ajax_referer( "delete-comment_$id" );
     
    306306        if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
    307307                if ( 'trash' == $status )
    308                         die( (string) time() );
     308                        wp_die( time() );
    309309                $r = wp_trash_comment( $comment->comment_ID );
    310310        } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
    311311                if ( 'trash' != $status )
    312                         die( (string) time() );
     312                        wp_die( time() );
    313313                $r = wp_untrash_comment( $comment->comment_ID );
    314314                if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
     
    316316        } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
    317317                if ( 'spam' == $status )
    318                         die( (string) time() );
     318                        wp_die( time() );
    319319                $r = wp_spam_comment( $comment->comment_ID );
    320320        } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
    321321                if ( 'spam' != $status )
    322                         die( (string) time() );
     322                        wp_die( time() );
    323323                $r = wp_unspam_comment( $comment->comment_ID );
    324324                if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
     
    327327                $r = wp_delete_comment( $comment->comment_ID );
    328328        } else {
    329                 die('-1');
     329                wp_die( -1 );
    330330        }
    331331
    332332        if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
    333333                _wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
    334         die( '0' );
     334        wp_die( 0 );
    335335}
    336336
     
    343343
    344344        if ( !current_user_can( $tax->cap->delete_terms ) )
    345                 die('-1');
     345                wp_die( -1 );
    346346
    347347        $tag = get_term( $tag_id, $taxonomy );
    348348        if ( !$tag || is_wp_error( $tag ) )
    349                 die('1');
     349                wp_die( 1 );
    350350
    351351        if ( wp_delete_term($tag_id, $taxonomy))
    352                 die('1');
     352                wp_die( 1 );
    353353        else
    354                 die('0');
     354                wp_die( 0 );
    355355}
    356356
     
    360360        check_ajax_referer( "delete-bookmark_$id" );
    361361        if ( !current_user_can( 'manage_links' ) )
    362                 die('-1');
     362                wp_die( -1 );
    363363
    364364        $link = get_bookmark( $id );
    365365        if ( !$link || is_wp_error( $link ) )
    366                 die('1');
     366                wp_die( 1 );
    367367
    368368        if ( wp_delete_link( $id ) )
    369                 die('1');
     369                wp_die( 1 );
    370370        else
    371                 die('0');
     371                wp_die( 0 );
    372372}
    373373
     
    377377        check_ajax_referer( "delete-meta_$id" );
    378378        if ( !$meta = get_metadata_by_mid( 'post', $id ) )
    379                 die('1');
     379                wp_die( 1 );
    380380
    381381        if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) )
    382                 die('-1');
     382                wp_die( -1 );
    383383        if ( delete_meta( $meta->meta_id ) )
    384                 die('1');
    385         die('0');
     384                wp_die( 1 );
     385        wp_die( 0 );
    386386}
    387387
     
    391391        check_ajax_referer( "{$action}_$id" );
    392392        if ( !current_user_can( 'delete_post', $id ) )
    393                 die('-1');
     393                wp_die( -1 );
    394394
    395395        if ( !get_post( $id ) )
    396                 die('1');
     396                wp_die( 1 );
    397397
    398398        if ( wp_delete_post( $id ) )
    399                 die('1');
     399                wp_die( 1 );
    400400        else
    401                 die('0');
     401                wp_die( 0 );
    402402}
    403403
     
    407407        check_ajax_referer( "{$action}_$id" );
    408408        if ( !current_user_can( 'delete_post', $id ) )
    409                 die('-1');
     409                wp_die( -1 );
    410410
    411411        if ( !get_post( $id ) )
    412                 die('1');
     412                wp_die( 1 );
    413413
    414414        if ( 'trash-post' == $action )
     
    418418
    419419        if ( $done )
    420                 die('1');
    421 
    422         die('0');
     420                wp_die( 1 );
     421
     422        wp_die( 0 );
    423423}
    424424
     
    432432        check_ajax_referer( "{$action}_$id" );
    433433        if ( !current_user_can( 'delete_page', $id ) )
    434                 die('-1');
     434                wp_die( -1 );
    435435
    436436        if ( !get_page( $id ) )
    437                 die('1');
     437                wp_die( 1 );
    438438
    439439        if ( wp_delete_post( $id ) )
    440                 die('1');
     440                wp_die( 1 );
    441441        else
    442                 die('0');
     442                wp_die( 0 );
    443443}
    444444
     
    455455
    456456        if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
    457                 die('-1');
     457                wp_die( -1 );
    458458
    459459        $current = wp_get_comment_status( $comment->comment_ID );
    460460        if ( $_POST['new'] == $current )
    461                 die( (string) time() );
     461                wp_die( time() );
    462462
    463463        check_ajax_referer( "approve-comment_$id" );
     
    477477        // Decide if we need to send back '1' or a more complicated response including page links and comment counts
    478478        _wp_ajax_delete_comment_response( $comment->comment_ID );
    479         die( '0' );
     479        wp_die( 0 );
    480480}
    481481
     
    483483        check_ajax_referer( $action );
    484484        if ( !current_user_can( 'manage_categories' ) )
    485                 die('-1');
     485                wp_die( -1 );
    486486        $names = explode(',', $_POST['newcat']);
    487487        $x = new WP_Ajax_Response();
     
    517517
    518518        if ( !current_user_can( $tax->cap->edit_terms ) )
    519                 die('-1');
     519                wp_die( -1 );
    520520
    521521        $x = new WP_Ajax_Response();
     
    568568                $tax = get_taxonomy( $taxonomy );
    569569                if ( ! $tax )
    570                         die( '0' );
     570                        wp_die( 0 );
    571571                if ( ! current_user_can( $tax->cap->assign_terms ) )
    572                         die( '-1' );
     572                        wp_die( -1 );
    573573        } else {
    574                 die('0');
     574                wp_die( 0 );
    575575        }
    576576
     
    578578
    579579        if ( empty( $tags ) )
    580                 die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
     580                wp_die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
    581581
    582582        if ( is_wp_error( $tags ) )
    583                 die( $tags->get_error_message() );
     583                wp_die( $tags->get_error_message() );
    584584
    585585        foreach ( $tags as $key => $tag ) {
     
    592592
    593593        if ( empty($return) )
    594                 die('0');
     594                wp_die( 0 );
    595595
    596596        echo $return;
    597597
    598         exit;
     598        wp_die();
    599599}
    600600
     
    609609
    610610        if ( !current_user_can( 'edit_post', $post_id ) )
    611                 die('-1');
     611                wp_die( -1 );
    612612
    613613        $wp_list_table->prepare_items();
    614614
    615615        if ( !$wp_list_table->has_items() )
    616                 die('1');
     616                wp_die( 1 );
    617617
    618618        $x = new WP_Ajax_Response();
     
    643643        $comment_post_ID = (int) $_POST['comment_post_ID'];
    644644        if ( !current_user_can( 'edit_post', $comment_post_ID ) )
    645                 die('-1');
     645                wp_die( -1 );
    646646
    647647        $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
    648648
    649649        if ( empty($status) )
    650                 die('1');
     650                wp_die( 1 );
    651651        elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
    652                 die( __('ERROR: you are replying to a comment on a draft post.') );
     652                wp_die( __('ERROR: you are replying to a comment on a draft post.') );
    653653
    654654        $user = wp_get_current_user();
     
    665665                }
    666666        } else {
    667                 die( __('Sorry, you must be logged in to reply to a comment.') );
     667                wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
    668668        }
    669669
    670670        if ( '' == $comment_content )
    671                 die( __('ERROR: please type a comment.') );
     671                wp_die( __( 'ERROR: please type a comment.' ) );
    672672
    673673        $comment_parent = absint($_POST['comment_ID']);
     
    677677        $comment_id = wp_new_comment( $commentdata );
    678678        $comment = get_comment($comment_id);
    679         if ( ! $comment ) die('1');
     679        if ( ! $comment ) wp_die( 1 );
    680680
    681681        $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
     
    730730        $comment_id = (int) $_POST['comment_ID'];
    731731        if ( ! current_user_can( 'edit_comment', $comment_id ) )
    732                 die('-1');
     732                wp_die( -1 );
    733733
    734734        if ( '' == $_POST['content'] )
    735                 die( __('ERROR: please type a comment.') );
     735                wp_die( __( 'ERROR: please type a comment.' ) );
    736736
    737737        $_POST['comment_status'] = $_POST['status'];
     
    765765function wp_ajax_add_menu_item() {
    766766        if ( ! current_user_can( 'edit_theme_options' ) )
    767                 die('-1');
     767                wp_die( -1 );
    768768
    769769        check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
     
    803803        $item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
    804804        if ( is_wp_error( $item_ids ) )
    805                 die('-1');
     805                wp_die( -1 );
    806806
    807807        $menu_items = array();
     
    836836        if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
    837837                if ( !current_user_can( 'edit_post', $pid ) )
    838                         die('-1');
     838                        wp_die( -1 );
    839839                if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
    840                         die('1');
     840                        wp_die( 1 );
    841841                if ( $post->post_status == 'auto-draft' ) {
    842842                        $save_POST = $_POST; // Backup $_POST
     
    859859                                $_POST = $save_POST; // Now we can restore original $_POST again
    860860                                if ( !$mid = add_meta( $pid ) )
    861                                         die(__('Please provide a custom field value.'));
     861                                        wp_die( __( 'Please provide a custom field value.' ) );
    862862                        } else {
    863                                 die('0');
     863                                wp_die( 0 );
    864864                        }
    865865                } else if ( !$mid = add_meta( $pid ) ) {
    866                         die(__('Please provide a custom field value.'));
     866                        wp_die( __( 'Please provide a custom field value.' ) );
    867867                }
    868868
     
    882882                $value = stripslashes( $_POST['meta'][$mid]['value'] );
    883883                if ( '' == trim($key) )
    884                         die(__('Please provide a custom field name.'));
     884                        wp_die( __( 'Please provide a custom field name.' ) );
    885885                if ( '' == trim($value) )
    886                         die(__('Please provide a custom field value.'));
     886                        wp_die( __( 'Please provide a custom field value.' ) );
    887887                if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
    888                         die('0'); // if meta doesn't exist
     888                        wp_die( 0 ); // if meta doesn't exist
    889889                if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
    890890                        ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
    891891                        ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
    892                         die('-1');
     892                        wp_die( -1 );
    893893                if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
    894894                        if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
    895                                 die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
     895                                wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
    896896                }
    897897
     
    916916        check_ajax_referer( $action );
    917917        if ( ! current_user_can('create_users') )
    918                 die('-1');
     918                wp_die( -1 );
    919919        if ( ! $user_id = edit_user() ) {
    920                 die('0');
     920                wp_die( 0 );
    921921        } elseif ( is_wp_error( $user_id ) ) {
    922922                $x = new WP_Ajax_Response( array(
     
    987987        if ( 'page' == $post->post_type ) {
    988988                if ( !current_user_can('edit_page', $post_ID) )
    989                         die(__('You are not allowed to edit this page.'));
     989                        wp_die( __( 'You are not allowed to edit this page.' ) );
    990990        } else {
    991991                if ( !current_user_can('edit_post', $post_ID) )
    992                         die(__('You are not allowed to edit this post.'));
     992                        wp_die( __( 'You are not allowed to edit this post.' ) );
    993993        }
    994994
     
    10541054
    10551055        if ( $page != sanitize_key( $page ) )
    1056                 die('0');
     1056                wp_die( 0 );
    10571057
    10581058        if ( ! $user = wp_get_current_user() )
    1059                 die('-1');
     1059                wp_die( -1 );
    10601060
    10611061        if ( is_array($closed) )
     
    10671067        }
    10681068
    1069         die('1');
     1069        wp_die( 1 );
    10701070}
    10711071
     
    10771077
    10781078        if ( $page != sanitize_key( $page ) )
    1079                 die('0');
     1079                wp_die( 0 );
    10801080
    10811081        if ( ! $user = wp_get_current_user() )
    1082                 die('-1');
     1082                wp_die( -1 );
    10831083
    10841084        if ( is_array($hidden) )
    10851085                update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
    10861086
    1087         die('1');
     1087        wp_die( 1 );
    10881088}
    10891089
     
    10921092
    10931093        if ( ! current_user_can( 'edit_theme_options' ) )
    1094                 die('-1');
     1094                wp_die( -1 );
    10951095
    10961096        update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
    10971097
    1098         die('1');
     1098        wp_die( 1 );
    10991099}
    11001100
    11011101function wp_ajax_menu_get_metabox() {
    11021102        if ( ! current_user_can( 'edit_theme_options' ) )
    1103                 die('-1');
     1103                wp_die( -1 );
    11041104
    11051105        require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
     
    11361136        }
    11371137
    1138         exit;
     1138        wp_die();
    11391139}
    11401140
     
    11521152
    11531153        if ( ! isset( $results ) )
    1154                 die( '0' );
     1154                wp_die( 0 );
    11551155
    11561156        echo json_encode( $results );
    11571157        echo "\n";
    11581158
    1159         exit;
     1159        wp_die();
    11601160}
    11611161
    11621162function wp_ajax_menu_locations_save() {
    11631163        if ( ! current_user_can( 'edit_theme_options' ) )
    1164                 die('-1');
     1164                wp_die( -1 );
    11651165        check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
    11661166        if ( ! isset( $_POST['menu-locations'] ) )
    1167                 die('0');
     1167                wp_die( 0 );
    11681168        set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
    1169         die('1');
     1169        wp_die( 1 );
    11701170}
    11711171
     
    11811181
    11821182        if ( $page != sanitize_key( $page ) )
    1183                 die('0');
     1183                wp_die( 0 );
    11841184
    11851185        if ( ! $user = wp_get_current_user() )
    1186                 die('-1');
     1186                wp_die( -1 );
    11871187
    11881188        if ( $order )
     
    11921192                update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
    11931193
    1194         die('1');
     1194        wp_die( 1 );
    11951195}
    11961196
    11971197function wp_ajax_menu_quick_search() {
    11981198        if ( ! current_user_can( 'edit_theme_options' ) )
    1199                 die('-1');
     1199                wp_die( -1 );
    12001200
    12011201        require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
     
    12031203        _wp_ajax_menu_quick_search( $_POST );
    12041204
    1205         exit;
     1205        wp_die();
    12061206}
    12071207
     
    12091209        check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
    12101210        $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
    1211         die(add_query_arg(array('preview' => 'true'), get_permalink($post_id)));
     1211        wp_die( add_query_arg( array( 'preview' => 'true' ), get_permalink( $post_id ) ) );
    12121212}
    12131213
     
    12171217        $title = isset($_POST['new_title'])? $_POST['new_title'] : '';
    12181218        $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
    1219         die(get_sample_permalink_html($post_id, $title, $slug));
     1219        wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
    12201220}
    12211221
     
    12261226
    12271227        if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
    1228                 exit;
     1228                wp_die();
    12291229
    12301230        if ( 'page' == $_POST['post_type'] ) {
    12311231                if ( ! current_user_can( 'edit_page', $post_ID ) )
    1232                         die( __('You are not allowed to edit this page.') );
     1232                        wp_die( __( 'You are not allowed to edit this page.' ) );
    12331233        } else {
    12341234                if ( ! current_user_can( 'edit_post', $post_ID ) )
    1235                         die( __('You are not allowed to edit this post.') );
     1235                        wp_die( __( 'You are not allowed to edit this post.' ) );
    12361236        }
    12371237
     
    12421242                $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
    12431243                printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ),        esc_html( $last_user_name ) );
    1244                 exit;
     1244                wp_die();
    12451245        }
    12461246
     
    12781278        $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
    12791279
    1280         exit;
     1280        wp_die();
    12811281}
    12821282
     
    12891289        $tax = get_taxonomy( $taxonomy );
    12901290        if ( ! $tax )
    1291                 die( '0' );
     1291                wp_die( 0 );
    12921292
    12931293        if ( ! current_user_can( $tax->cap->edit_terms ) )
    1294                 die( '-1' );
     1294                wp_die( -1 );
    12951295
    12961296        set_current_screen( 'edit-' . $taxonomy );
     
    12991299
    13001300        if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
    1301                 die(-1);
     1301                wp_die( -1 );
    13021302
    13031303        $tag = get_term( $id, $taxonomy );
     
    13091309                if ( !$tag || is_wp_error( $tag ) ) {
    13101310                        if ( is_wp_error($tag) && $tag->get_error_message() )
    1311                                 die( $tag->get_error_message() );
    1312                         die( __('Item not updated.') );
     1311                                wp_die( $tag->get_error_message() );
     1312                        wp_die( __( 'Item not updated.' ) );
    13131313                }
    13141314
     
    13161316        } else {
    13171317                if ( is_wp_error($updated) && $updated->get_error_message() )
    1318                         die( $updated->get_error_message() );
    1319                 die( __('Item not updated.') );
    1320         }
    1321 
    1322         exit;
     1318                        wp_die( $updated->get_error_message() );
     1319                wp_die( __( 'Item not updated.' ) );
     1320        }
     1321
     1322        wp_die();
    13231323}
    13241324
     
    13291329
    13301330        if ( empty($_POST['ps']) )
    1331                 exit;
     1331                wp_die();
    13321332
    13331333        if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )
     
    13541354        if ( ! $posts ) {
    13551355                $posttype = get_post_type_object($what);
    1356                 exit($posttype->labels->not_found);
     1356                wp_die( $posttype->labels->not_found );
    13571357        }
    13581358
     
    14011401
    14021402        if ( !current_user_can('edit_theme_options') )
    1403                 die('-1');
     1403                wp_die( -1 );
    14041404
    14051405        unset( $_POST['savewidgets'], $_POST['action'] );
     
    14221422                }
    14231423                wp_set_sidebars_widgets($sidebars);
    1424                 die('1');
    1425         }
    1426 
    1427         die('-1');
     1424                wp_die( 1 );
     1425        }
     1426
     1427        wp_die( -1 );
    14281428}
    14291429
     
    14341434
    14351435        if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
    1436                 die('-1');
     1436                wp_die( -1 );
    14371437
    14381438        unset( $_POST['savewidgets'], $_POST['action'] );
     
    14561456
    14571457                if ( !isset($wp_registered_widgets[$widget_id]) )
    1458                         die($error);
     1458                        wp_die( $error );
    14591459
    14601460                $sidebar = array_diff( $sidebar, array($widget_id) );
     
    14621462        } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
    14631463                if ( !$multi_number )
    1464                         die($error);
     1464                        wp_die( $error );
    14651465
    14661466                $_POST['widget-' . $id_base] = array( $multi_number => array_shift($settings) );
     
    14871487                wp_set_sidebars_widgets($sidebars);
    14881488                echo "deleted:$widget_id";
    1489                 die();
     1489                wp_die();
    14901490        }
    14911491
    14921492        if ( !empty($_POST['add_new']) )
    1493                 die();
     1493                wp_die();
    14941494
    14951495        if ( $form = $wp_registered_widget_controls[$widget_id] )
    14961496                call_user_func_array( $form['callback'], $form['params'] );
    14971497
    1498         die();
     1498        wp_die();
    14991499}
    15001500
     
    15021502        $attachment_id = intval($_POST['postid']);
    15031503        if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
    1504                 die('-1');
     1504                wp_die( -1 );
    15051505
    15061506        check_ajax_referer( "image_editor-$attachment_id" );
     
    15121512                        $msg = wp_save_image($attachment_id);
    15131513                        $msg = json_encode($msg);
    1514                         die($msg);
     1514                        wp_die( $msg );
    15151515                        break;
    15161516                case 'scale' :
     
    15231523
    15241524        wp_image_editor($attachment_id, $msg);
    1525         die();
     1525        wp_die();
    15261526}
    15271527
     
    15291529        $post_ID = intval( $_POST['post_id'] );
    15301530        if ( !current_user_can( 'edit_post', $post_ID ) )
    1531                 die( '-1' );
     1531                wp_die( -1 );
    15321532        $thumbnail_id = intval( $_POST['thumbnail_id'] );
    15331533
     
    15361536        if ( $thumbnail_id == '-1' ) {
    15371537                if ( delete_post_thumbnail( $post_ID ) )
    1538                         die( _wp_post_thumbnail_html() );
     1538                        wp_die( _wp_post_thumbnail_html() );
    15391539                else
    1540                         die( '0' );
     1540                        wp_die( 0 );
    15411541        }
    15421542
    15431543        if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
    1544                 die( _wp_post_thumbnail_html( $thumbnail_id ) );
    1545         die( '0' );
     1544                wp_die( _wp_post_thumbnail_html( $thumbnail_id ) );
     1545        wp_die( 0 );
    15461546}
    15471547
    15481548function wp_ajax_date_format() {
    1549         die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) );
     1549        wp_die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) );
    15501550}
    15511551
    15521552function wp_ajax_time_format() {
    1553         die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
     1553        wp_die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
    15541554}
    15551555
     
    15781578
    15791579                echo json_encode( array( 'message' => $message, 'last_edited' => '' ) );
    1580                 die();
     1580                wp_die();
    15811581        } else {
    15821582                $message = __('Saved.');
     
    15991599
    16001600        echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );
    1601         die();
     1601        wp_die();
    16021602}
    16031603
    16041604function wp_ajax_wp_remove_post_lock() {
    16051605        if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
    1606                 die( '0' );
     1606                wp_die( 0 );
    16071607        $post_id = (int) $_POST['post_ID'];
    16081608        if ( ! $post = get_post( $post_id ) )
    1609                 die( '0' );
     1609                wp_die( 0 );
    16101610
    16111611        check_ajax_referer( 'update-' . $post->post_type . '_' . $post_id );
    16121612
    16131613        if ( ! current_user_can( 'edit_post', $post_id ) )
    1614                 die( '-1' );
     1614                wp_die( -1 );
    16151615
    16161616        $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
    16171617        if ( $active_lock[1] != get_current_user_id() )
    1618                 die( '0' );
     1618                wp_die( 0 );
    16191619
    16201620        $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1];
    16211621        update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
    1622         die( '1' );
     1622        wp_die( 1 );
    16231623}
    16241624
     
    16261626        $pointer = $_POST['pointer'];
    16271627        if ( $pointer != sanitize_key( $pointer ) )
    1628                 die( '0' );
     1628                wp_die( 0 );
    16291629
    16301630//      check_ajax_referer( 'dismiss-pointer_' . $pointer );
     
    16331633
    16341634        if ( in_array( $pointer, $dismissed ) )
    1635                 die( '0' );
     1635                wp_die( 0 );
    16361636
    16371637        $dismissed[] = $pointer;
     
    16391639
    16401640        update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
    1641         die( '1' );
    1642 }
     1641        wp_die( 1 );
     1642}
Note: See TracChangeset for help on using the changeset viewer.