WordPress.org

Make WordPress Core

Ticket #25669: 256691.patch

File 256691.patch, 11.7 KB (added by sebastian.pisula, 3 years ago)
  • wp-admin/includes/dashboard.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax();
    970970
    971971        if ( empty($check_urls) ) {
    972972                $widgets = get_option( 'dashboard_widget_options' );
  • wp-admin/includes/class-wp-terms-list-table.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    371371
    372372                $edit_link = add_query_arg(
    373373                        'wp_http_referer',
     
    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_is_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    429429
    430430                $edit_link = add_query_arg(
    431431                        'wp_http_referer',
  • wp-admin/includes/theme.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_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 );
  • wp-includes/option.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    786786 */
    787787function wp_user_settings() {
    788788
    789         if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
     789        if ( ! is_admin() || wp_is_ajax() ) {
    790790                return;
    791791        }
    792792
  • wp-admin/includes/ms.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() ) {
    4444                wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    4545        }
    4646
  • wp-includes/update.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() ) {
    682682        return;
    683683}
    684684
  • wp-includes/comment.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    632632                 * @param array $commentdata Comment data.
    633633                 */
    634634                do_action( 'comment_duplicate_trigger', $commentdata );
    635                 if ( defined( 'DOING_AJAX' ) ) {
     635                if ( wp_is_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 );
     
    768768                         */
    769769                        do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
    770770
    771                         if ( defined('DOING_AJAX') )
     771                        if ( wp_is_ajax() )
    772772                                die( __('You are posting comments too quickly. Slow down.') );
    773773
    774774                        wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
  • wp-includes/pluggable.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
    607607                $expired += HOUR_IN_SECONDS;
    608608        }
    609609
     
    11041104        do_action( 'check_ajax_referer', $action, $result );
    11051105
    11061106        if ( $die && false === $result ) {
    1107                 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     1107                if ( wp_is_ajax() ) {
    11081108                        wp_die( -1 );
    11091109                } else {
    11101110                        die( '-1' );
  • wp-admin/includes/class-wp-list-table.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
    288288                        wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
    289289                        exit;
    290290                }
  • wp-includes/class-wp-ajax-response.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    149149                foreach ( (array) $this->responses as $response )
    150150                        echo $response;
    151151                echo '</wp_ajax>';
    152                 if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
     152                if ( wp_is_ajax() )
    153153                        wp_die();
    154154                else
    155155                        die();
  • wp-includes/load.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() ) {
    338338                @ini_set( 'display_errors', 0 );
    339339        }
    340340}
     
    10261026        }
    10271027
    10281028        return false;
    1029 }
     1029}
     1030
     1031/**
     1032 * Whether the current request is for an admin ajax page.
     1033 *
     1034 * @since 4.7.0
     1035 *
     1036 * @return bool
     1037 */
     1038function wp_is_ajax() {
     1039        return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
     1040}
     1041 No newline at end of file
  • wp-admin/includes/class-wp-comments-list-table.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    9494
    9595                $comments_per_page = $this->get_per_page( $comment_status );
    9696
    97                 $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
     97                $doing_ajax = wp_is_ajax();
    9898
    9999                if ( isset( $_REQUEST['number'] ) ) {
    100100                        $number = (int) $_REQUEST['number'];
     
    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_is_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 ) )
  • wp-includes/class-wp-customize-manager.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    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_is_ajax() ) {
    320319                        return false;
    321320                }
    322321
  • wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    25672567                $title = '';
    25682568        }
    25692569
    2570         if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
     2570        if ( wp_is_ajax() ) {
    25712571                /**
    25722572                 * Filters the callback for killing WordPress execution for Ajax requests.
    25732573                 *
     
    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_is_ajax() )
    30653065                wp_die();
    30663066        else
    30673067                die;