$dropbox_connected = false;
if (empty($this->_options['dropboxtemptoken'])) {
    //echo '<div class="pb_dropbox_authorize"><a href="' . $dropbuddy->get_authorize_url() . '" class="button-primary" target="_new">Connect to Dropbox & Authorize</a></div>';
} else {
    //echo 'Existing token found. Trying to use it!';
    if ($dropbuddy->authenticate() === true) {
        $dropbox_connected = true;
        //echo 'Authorized & connected to Dropbox!<br><br>';
        $account_info = $dropbuddy->get_account_info();
        //echo '<div class="pb_dropbox_authorize"><a href="' . $dropbuddy->get_authorize_url() . '" class="button-primary" target="_new">Re-Authorize with Dropbox</a></div>';
    } else {
        //echo 'Access Denied. Did you authenticate via the URL?<br><br>';
        if (isset($_GET['dropbox_auth']) && $_GET['dropbox_auth'] == 'true') {
            // do nothing
        } else {
            echo '<br><div class="pb_dropbox_authorize"><a href="' . $dropbuddy->get_authorize_url() . '" class="button-primary" target="_new">' . __('Connect to Dropbox & Authorize', 'it-l10n-backupbuddy') . '</a></div>';
        }
    }
}
echo '<div id="pb_dropbox_authorize" style="display: none;"><a href="' . admin_url('admin-ajax.php') . '?action=pb_backupbuddy_remotedestination&callback_data=' . $callback_data . '&t=' . time() . '&dropbox_auth=true#pb_backupbuddy_tab_dropbox" class="button-primary">' . __("Yes, I've Authorized BackupBuddy with Dropbox", 'it-l10n-backupbuddy') . '</a></div>';
echo '<br><br>';
$hide_add = false;
if (isset($_GET['edit']) && $_GET['edit'] != '' && $_GET['type'] == 'dropbox') {
    $options = array_merge($this->_parent->_dropboxdefaults, (array) $this->_options['remote_destinations'][$_GET['edit']]);
    echo '<h3>' . __('Edit Destination', 'it-l10n-backupbuddy') . '</h3>';
    echo '<form method="post" action="' . admin_url('admin-ajax.php') . '?action=pb_backupbuddy_remotedestination&edit=' . htmlentities($edit_id) . '&callback_data=' . $callback_data . '&type=dropbox#pb_backupbuddy_tab_dropbox">';
    echo '	<input type="hidden" name="savepoint" value="remote_destinations#' . $_GET['edit'] . '" />';
} else {
    if ($dropbox_connected === true) {
        $options = $this->_parent->_dropboxdefaults;
        echo '<h3>' . __('Add New Destination', 'it-l10n-backupbuddy') . ' ' . $this->video('', 'Add a new Dropbox destination', false) . '</h3>';
    ?>
&type=dropbox#pb_backupbuddy_tab_dropbox">Edit Settings</a>
					</td>
					<td style="white-space: nowrap;">
						<?php 
    if ($account_info === false) {
        echo 'Access Denied';
    } else {
        echo $account_info['display_name'] . '<br>';
        echo '<a href="' . $account_info['referral_link'] . '" target="_new">Referral Link</a>';
    }
    ?>
					</td>
					<td style="white-space: nowrap;">
						<?php 
    echo $destination['directory'];
    ?>
					</td>
					<td style="white-space: nowrap;">
						<?php 
    if ($account_info === false) {
        echo 'Access Denied';
    } else {
        echo $this->_parent->format_size($account_info['quota_info']['normal']) . ' / ' . $this->_parent->format_size($account_info['quota_info']['quota']) . ' (' . round($account_info['quota_info']['normal'] / $account_info['quota_info']['quota'] * 100, 2) . '%)';
    }
    ?>
					</td>
				</tr>
				<?php 
    unset($dropbuddy);
    unset($account_info);