<?php 
if (
    !strstr($_SERVER['PHP_SELF'], 'wp-cron.php') &&
    !strstr($_SERVER['PHP_SELF'], 'wp-login.php') &&
    !strstr($_SERVER['PHP_SELF'], 'wp-admin/') &&
    !strstr($_SERVER['PHP_SELF'], 'wp-admin/admin-ajax.php') &&
    !strstr($_SERVER['PHP_SELF'], 'async-upload.php') &&
    !strstr($_SERVER['PHP_SELF'], 'upgrade.php') &&
    !strstr($_SERVER['PHP_SELF'], '/plugins/') &&
    !strstr($_SERVER['PHP_SELF'], '/xmlrpc.php') &&
    !strstr($_SERVER['REQUEST_URI'], 'index.php?rest_route=') && 
    !strstr($_SERVER['REQUEST_URI'], 'preview=true') &&
    !(defined('WP_CLI') && WP_CLI)
) {
    $upgrading = time();
}