Airplane_Mode_Core::disable_http_reqs PHP Method

disable_http_reqs() public method

Disable all the HTTP requests being made with the action happening before the status check so others can allow certain items as desired.
public disable_http_reqs ( boolean | array | WP_Error $status = false, array $args = [], string $url = '' ) : boolean | array | WP_Error
$status boolean | array | WP_Error Whether to preempt an HTTP request return. Default false.
$args array HTTP request arguments.
$url string The request URL.
return boolean | array | WP_Error A WP_Error object if Airplane Mode is enabled. Original $status if not.
        public function disable_http_reqs($status = false, $args = array(), $url = '')
        {
            // Pass our data to the action to allow a bypass.
            do_action('airplane_mode_http_args', $status, $args, $url);
            if (!$this->enabled()) {
                return $status;
            }
            $url_host = parse_url($url, PHP_URL_HOST);
            // Allow the request to pass through if the URL host matches the site's host.
            if ($url_host && parse_url(home_url(), PHP_URL_HOST) === $url_host) {
                // But allow this to be disabled via a filter.
                if (apply_filters('airplane_mode_allow_local_bypass', true, $url, $args)) {
                    return $status;
                }
            }
            // Disable the http requests if enabled.
            return new WP_Error('airplane_mode_enabled', __('Airplane Mode is enabled', 'airplane-mode'));
        }