Skip to Content
Menu

is_background_request()

If the current process is not a “visual” navigation request.

PHP April 1, 2021

Usage

PHP
nebula()->is_background_request()

Parameters

This function does not accept any parameters. Is this incorrect?

Additional Notes

This function is true if the current request is an AJAX, REST, CRON, XMLRPC, or WP installation.

This is great for optimizing server-side functionality that is only meant to be run either during, or not during one of these “background” requests.

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Utilities/Utilities.php on line 1177.

    No Hooks

    This function does not have any filters or actions available. Request one?
    PHP
            public function is_background_request(){
                //Check for AJAX
                if ( $this->is_ajax_request() ){
                    return true;
                }
    
                //Check for the REST API
                if ( (defined('REST_REQUEST') && REST_REQUEST) || isset($this->super->get['rest_route']) ){
                    return true;
                }
    
                //Check if a CRON is running
                if ( defined('DOING_CRON') && DOING_CRON ){
                    return true;
                }
    
                //Check if it is an XMLRPC request
                if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ){
                    return true;
                }
    
                //Check if WP is installing
                if ( defined('WP_INSTALLING') && WP_INSTALLING ){
                    return true;
                }
    
                //If autosaving
                if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
                    return false;
                }
    
                return false;
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?