VaultPress::do_pings PHP Method

do_pings() public method

public do_pings ( )
    function do_pings()
    {
        global $wpdb, $vaultpress_pings, $__vp_recursive_ping_lock;
        if (defined('WP_IMPORTING') && constant('WP_IMPORTING')) {
            return;
        }
        if (!isset($wpdb)) {
            $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
            $close_wpdb = true;
        } else {
            $close_wpdb = false;
        }
        if (!$vaultpress_pings['count']) {
            return;
        }
        // Short circuit the contact process if we know that we can't contact the service
        if (isset($__vp_recursive_ping_lock) && $__vp_recursive_ping_lock) {
            $this->ai_ping_insert(serialize($vaultpress_pings));
            if ($close_wpdb) {
                $wpdb->__destruct();
                unset($wpdb);
            }
            $this->reset_pings();
            return;
        }
        $ping_attempts = 0;
        do {
            $ping_attempts++;
            $rval = $this->contact_service('ping', array('args' => $vaultpress_pings));
            if ($rval || $ping_attempts >= 3) {
                break;
            }
            if (!$rval) {
                usleep(500000);
            }
        } while (true);
        if (!$rval) {
            if ($this->get_option('connection_error_code') !== -8) {
                // Do not save pings when the subscription is inactive.
                $__vp_recursive_ping_lock = true;
                $this->ai_ping_insert(serialize($vaultpress_pings));
            }
        }
        $this->reset_pings();
        if ($close_wpdb) {
            $wpdb->__destruct();
            unset($wpdb);
        }
        return $rval;
    }
VaultPress