Make WordPress Core

Ticket #25669: 25669.diff

File 25669.diff, 10.8 KB (added by swissspidy, 8 years ago)
  • src/wp-admin/includes/class-wp-comments-list-table.php

    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 { 
    9494
    9595                $comments_per_page = $this->get_per_page( $comment_status );
    9696
    97                 $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
     97                $doing_ajax = wp_doing_ajax();
    9898
    9999                if ( isset( $_REQUEST['number'] ) ) {
    100100                        $number = (int) $_REQUEST['number'];
    class WP_Comments_List_Table extends WP_List_Table { 
    600600                        ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
    601601
    602602                        // 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() )
    604604                                $action .= ' hide-if-no-js';
    605605                        elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
    606606                                if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
  • src/wp-admin/includes/class-wp-list-table.php

    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 { 
    284284                        $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
    285285
    286286                // 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'] ) {
    288288                        wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
    289289                        exit;
    290290                }
  • src/wp-admin/includes/class-wp-terms-list-table.php

    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 { 
    367367
    368368                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    369369
    370                 $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     370                $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    371371
    372372                $edit_link = add_query_arg(
    373373                        'wp_http_referer',
    class WP_Terms_List_Table extends WP_List_Table { 
    425425                $tax = get_taxonomy( $taxonomy );
    426426                $default_term = get_option( 'default_' . $taxonomy );
    427427
    428                 $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     428                $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    429429
    430430                $edit_link = add_query_arg(
    431431                        'wp_http_referer',
  • src/wp-admin/includes/dashboard.php

    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 ) { 
    966966 */
    967967function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
    968968        $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</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();
    970970
    971971        if ( empty($check_urls) ) {
    972972                $widgets = get_option( 'dashboard_widget_options' );
  • src/wp-admin/includes/ms.php

    diff --git src/wp-admin/includes/ms.php src/wp-admin/includes/ms.php
    index c88123a..b2e4f86 100644
    function check_upload_size( $file ) { 
    4040                $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    4141        }
    4242
    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() ) {
    4444                wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    4545        }
    4646
  • src/wp-admin/includes/theme.php

    diff --git src/wp-admin/includes/theme.php src/wp-admin/includes/theme.php
    index 73567e1..9fbd712 100644
    function themes_api( $action, $args = array() ) { 
    459459                $request = wp_remote_post( $url, $http_args );
    460460
    461461                if ( $ssl && is_wp_error( $request ) ) {
    462                         if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
     462                        if ( ! wp_doing_ajax() ) {
    463463                                trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;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 );
    464464                        }
    465465                        $request = wp_remote_post( $http_url, $http_args );
  • src/wp-includes/class-wp-ajax-response.php

    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 { 
    149149                foreach ( (array) $this->responses as $response )
    150150                        echo $response;
    151151                echo '</wp_ajax>';
    152                 if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
     152                if ( wp_doing_ajax() )
    153153                        wp_die();
    154154                else
    155155                        die();
  • src/wp-includes/class-wp-customize-manager.php

    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 { 
    315315         * @return bool True if it's an Ajax request, false otherwise.
    316316         */
    317317        public function doing_ajax( $action = null ) {
    318                 $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
    319                 if ( ! $doing_ajax ) {
     318                if ( ! wp_doing_ajax() ) {
    320319                        return false;
    321320                }
    322321
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index dad3f76..debff11 100644
    function wp_allow_comment( $commentdata ) { 
    632632                 * @param array $commentdata Comment data.
    633633                 */
    634634                do_action( 'comment_duplicate_trigger', $commentdata );
    635                 if ( defined( 'DOING_AJAX' ) ) {
     635                if ( wp_doing_ajax() ) {
    636636                        die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
    637637                }
    638638                wp_die( __( 'Duplicate comment detected; it looks as though you&#8217;ve already said that!' ), 409 );
    function check_comment_flood_db( $ip, $email, $date ) { 
    768768                         */
    769769                        do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
    770770
    771                         if ( defined('DOING_AJAX') )
     771                        if ( wp_doing_ajax() )
    772772                                die( __('You are posting comments too quickly. Slow down.') );
    773773
    774774                        wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 204211b..53fe9dd 100644
    function wp_die( $message = '', $title = '', $args = array() ) { 
    25672567                $title = '';
    25682568        }
    25692569
    2570         if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     2570        if ( wp_doing_ajax() ) {
    25712571                /**
    25722572                 * Filters the callback for killing WordPress execution for Ajax requests.
    25732573                 *
    function _wp_json_prepare_data( $data ) { 
    30613061function wp_send_json( $response ) {
    30623062        @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
    30633063        echo wp_json_encode( $response );
    3064         if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
     3064        if ( wp_doing_ajax() )
    30653065                wp_die();
    30663066        else
    30673067                die;
  • src/wp-includes/load.php

    diff --git src/wp-includes/load.php src/wp-includes/load.php
    index c81cd9b..403d460 100644
    function wp_debug_mode() { 
    334334                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 );
    335335        }
    336336
    337         if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
     337        if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || wp_doing_ajax() ) {
    338338                @ini_set( 'display_errors', 0 );
    339339        }
    340340}
    function wp_is_ini_value_changeable( $setting ) { 
    10271027
    10281028        return false;
    10291029}
     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 */
     1038function 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}
  • src/wp-includes/option.php

    diff --git src/wp-includes/option.php src/wp-includes/option.php
    index 2f3cdd1..911d323 100644
    function set_transient( $transient, $value, $expiration = 0 ) { 
    786786 */
    787787function wp_user_settings() {
    788788
    789         if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
     789        if ( ! is_admin() || wp_doing_ajax() ) {
    790790                return;
    791791        }
    792792
  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 511e6ac..e4a31e4 100644
    function wp_validate_auth_cookie($cookie = '', $scheme = '') { 
    603603        $expired = $expiration = $cookie_elements['expiration'];
    604604
    605605        // 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'] ) {
    607607                $expired += HOUR_IN_SECONDS;
    608608        }
    609609
    function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { 
    11041104        do_action( 'check_ajax_referer', $action, $result );
    11051105
    11061106        if ( $die && false === $result ) {
    1107                 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     1107                if ( wp_doing_ajax() ) {
    11081108                        wp_die( -1 );
    11091109                } else {
    11101110                        die( '-1' );
  • src/wp-includes/update.php

    diff --git src/wp-includes/update.php src/wp-includes/update.php
    index 59b618c..5f074dc 100644
    function wp_clean_update_cache() { 
    678678        delete_site_transient( 'update_core' );
    679679}
    680680
    681 if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
     681if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) {
    682682        return;
    683683}
    684684