diff --git src/wp-admin/includes/class-wp-comments-list-table.php src/wp-admin/includes/class-wp-comments-list-table.php
index 116a55e..cb78018 100644
|
|
class WP_Comments_List_Table extends WP_List_Table { |
94 | 94 | |
95 | 95 | $comments_per_page = $this->get_per_page( $comment_status ); |
96 | 96 | |
97 | | $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
| 97 | $doing_ajax = wp_doing_ajax(); |
98 | 98 | |
99 | 99 | if ( isset( $_REQUEST['number'] ) ) { |
100 | 100 | $number = (int) $_REQUEST['number']; |
… |
… |
class WP_Comments_List_Table extends WP_List_Table { |
600 | 600 | ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
601 | 601 | |
602 | 602 | // Reply and quickedit need a hide-if-no-js span when not added with ajax |
603 | | if ( ( 'reply' === $action || 'quickedit' === $action ) && ! defined('DOING_AJAX') ) |
| 603 | if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) |
604 | 604 | $action .= ' hide-if-no-js'; |
605 | 605 | elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) { |
606 | 606 | if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) |
diff --git src/wp-admin/includes/class-wp-list-table.php src/wp-admin/includes/class-wp-list-table.php
index ee0f9af..6805351 100644
|
|
class WP_List_Table { |
284 | 284 | $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
285 | 285 | |
286 | 286 | // Redirect if page number is invalid and headers are not already sent. |
287 | | if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
| 287 | if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
288 | 288 | wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); |
289 | 289 | exit; |
290 | 290 | } |
diff --git src/wp-admin/includes/class-wp-terms-list-table.php src/wp-admin/includes/class-wp-terms-list-table.php
index e765794..638d4e7 100644
|
|
class WP_Terms_List_Table extends WP_List_Table { |
367 | 367 | |
368 | 368 | $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); |
369 | 369 | |
370 | | $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
| 370 | $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
371 | 371 | |
372 | 372 | $edit_link = add_query_arg( |
373 | 373 | 'wp_http_referer', |
… |
… |
class WP_Terms_List_Table extends WP_List_Table { |
425 | 425 | $tax = get_taxonomy( $taxonomy ); |
426 | 426 | $default_term = get_option( 'default_' . $taxonomy ); |
427 | 427 | |
428 | | $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
| 428 | $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
429 | 429 | |
430 | 430 | $edit_link = add_query_arg( |
431 | 431 | 'wp_http_referer', |
diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php
index e517f95..f923c70 100644
|
|
function wp_dashboard_rss_output( $widget_id ) { |
966 | 966 | */ |
967 | 967 | function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { |
968 | 968 | $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
969 | | $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
| 969 | $doing_ajax = wp_doing_ajax(); |
970 | 970 | |
971 | 971 | if ( empty($check_urls) ) { |
972 | 972 | $widgets = get_option( 'dashboard_widget_options' ); |
diff --git src/wp-admin/includes/ms.php src/wp-admin/includes/ms.php
index c88123a..b2e4f86 100644
|
|
function check_upload_size( $file ) { |
40 | 40 | $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); |
41 | 41 | } |
42 | 42 | |
43 | | if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { |
| 43 | if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) { |
44 | 44 | wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); |
45 | 45 | } |
46 | 46 | |
diff --git src/wp-admin/includes/theme.php src/wp-admin/includes/theme.php
index 73567e1..9fbd712 100644
|
|
function themes_api( $action, $args = array() ) { |
459 | 459 | $request = wp_remote_post( $url, $http_args ); |
460 | 460 | |
461 | 461 | if ( $ssl && is_wp_error( $request ) ) { |
462 | | if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { |
| 462 | if ( ! wp_doing_ajax() ) { |
463 | 463 | trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
464 | 464 | } |
465 | 465 | $request = wp_remote_post( $http_url, $http_args ); |
diff --git src/wp-includes/class-wp-ajax-response.php src/wp-includes/class-wp-ajax-response.php
index f02d24e..a86d8dd 100644
|
|
class WP_Ajax_Response { |
149 | 149 | foreach ( (array) $this->responses as $response ) |
150 | 150 | echo $response; |
151 | 151 | echo '</wp_ajax>'; |
152 | | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| 152 | if ( wp_doing_ajax() ) |
153 | 153 | wp_die(); |
154 | 154 | else |
155 | 155 | die(); |
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index 09e48b2..bbfb38c 100644
|
|
final class WP_Customize_Manager { |
315 | 315 | * @return bool True if it's an Ajax request, false otherwise. |
316 | 316 | */ |
317 | 317 | public function doing_ajax( $action = null ) { |
318 | | $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
319 | | if ( ! $doing_ajax ) { |
| 318 | if ( ! wp_doing_ajax() ) { |
320 | 319 | return false; |
321 | 320 | } |
322 | 321 | |
diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index dad3f76..debff11 100644
|
|
function wp_allow_comment( $commentdata ) { |
632 | 632 | * @param array $commentdata Comment data. |
633 | 633 | */ |
634 | 634 | do_action( 'comment_duplicate_trigger', $commentdata ); |
635 | | if ( defined( 'DOING_AJAX' ) ) { |
| 635 | if ( wp_doing_ajax() ) { |
636 | 636 | die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); |
637 | 637 | } |
638 | 638 | wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 ); |
… |
… |
function check_comment_flood_db( $ip, $email, $date ) { |
768 | 768 | */ |
769 | 769 | do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); |
770 | 770 | |
771 | | if ( defined('DOING_AJAX') ) |
| 771 | if ( wp_doing_ajax() ) |
772 | 772 | die( __('You are posting comments too quickly. Slow down.') ); |
773 | 773 | |
774 | 774 | wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); |
diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index 204211b..53fe9dd 100644
|
|
function wp_die( $message = '', $title = '', $args = array() ) { |
2567 | 2567 | $title = ''; |
2568 | 2568 | } |
2569 | 2569 | |
2570 | | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 2570 | if ( wp_doing_ajax() ) { |
2571 | 2571 | /** |
2572 | 2572 | * Filters the callback for killing WordPress execution for Ajax requests. |
2573 | 2573 | * |
… |
… |
function _wp_json_prepare_data( $data ) { |
3061 | 3061 | function wp_send_json( $response ) { |
3062 | 3062 | @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
3063 | 3063 | echo wp_json_encode( $response ); |
3064 | | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| 3064 | if ( wp_doing_ajax() ) |
3065 | 3065 | wp_die(); |
3066 | 3066 | else |
3067 | 3067 | die; |
diff --git src/wp-includes/load.php src/wp-includes/load.php
index c81cd9b..403d460 100644
|
|
function wp_debug_mode() { |
334 | 334 | error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
335 | 335 | } |
336 | 336 | |
337 | | if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
| 337 | if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || wp_doing_ajax() ) { |
338 | 338 | @ini_set( 'display_errors', 0 ); |
339 | 339 | } |
340 | 340 | } |
… |
… |
function wp_is_ini_value_changeable( $setting ) { |
1027 | 1027 | |
1028 | 1028 | return false; |
1029 | 1029 | } |
| 1030 | |
| 1031 | /** |
| 1032 | * Determines whether the current request is a WordPress Ajax request. |
| 1033 | * |
| 1034 | * @since 4.7.0 |
| 1035 | * |
| 1036 | * @return bool True if it's a WordPress Ajax request, false otherwise. |
| 1037 | */ |
| 1038 | function wp_doing_ajax() { |
| 1039 | /** |
| 1040 | * Filter whether the current request is a WordPress Ajax request. |
| 1041 | * |
| 1042 | * @since 4.7.0 |
| 1043 | * |
| 1044 | * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request. |
| 1045 | */ |
| 1046 | return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); |
| 1047 | } |
diff --git src/wp-includes/option.php src/wp-includes/option.php
index 2f3cdd1..911d323 100644
|
|
function set_transient( $transient, $value, $expiration = 0 ) { |
786 | 786 | */ |
787 | 787 | function wp_user_settings() { |
788 | 788 | |
789 | | if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
| 789 | if ( ! is_admin() || wp_doing_ajax() ) { |
790 | 790 | return; |
791 | 791 | } |
792 | 792 | |
diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index 511e6ac..e4a31e4 100644
|
|
function wp_validate_auth_cookie($cookie = '', $scheme = '') { |
603 | 603 | $expired = $expiration = $cookie_elements['expiration']; |
604 | 604 | |
605 | 605 | // Allow a grace period for POST and Ajax requests |
606 | | if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] ) { |
| 606 | if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) { |
607 | 607 | $expired += HOUR_IN_SECONDS; |
608 | 608 | } |
609 | 609 | |
… |
… |
function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { |
1104 | 1104 | do_action( 'check_ajax_referer', $action, $result ); |
1105 | 1105 | |
1106 | 1106 | if ( $die && false === $result ) { |
1107 | | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 1107 | if ( wp_doing_ajax() ) { |
1108 | 1108 | wp_die( -1 ); |
1109 | 1109 | } else { |
1110 | 1110 | die( '-1' ); |
diff --git src/wp-includes/update.php src/wp-includes/update.php
index 59b618c..5f074dc 100644
|
|
function wp_clean_update_cache() { |
678 | 678 | delete_site_transient( 'update_core' ); |
679 | 679 | } |
680 | 680 | |
681 | | if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
| 681 | if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) { |
682 | 682 | return; |
683 | 683 | } |
684 | 684 | |