WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/23/2016 02:32:18 PM (5 years ago)
Author:
wonderboymusic
Message:

AJAX: add a new function, wp_doing_ajax(), which can replace... (wait for it...) DOING_AJAX checks via the constant.

Props Mte90, sebastian.pisula, swissspidy.
Fixes #25669.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r38239 r38334  
    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    }
     
    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}
Note: See TracChangeset for help on using the changeset viewer.