Beispiel #1
0
    public function show_settings()
    {
        $post_data = Ithemes_Sync_Functions::get_post_data(array('username', 'password'), true);
        if (!is_multisite()) {
            $validations = $GLOBALS['ithemes-sync-settings']->validate_authentications();
        }
        $valid_users = array();
        $invalid_users = array();
        uksort($this->options['authentications'], array($this, 'sort_usernames'));
        foreach (array_keys($this->options['authentications']) as $user_id) {
            if (!isset($validations) || $validations[$user_id]) {
                $valid_users[] = $user_id;
            } else {
                $invalid_users[] = $user_id;
            }
        }
        ?>
	<div class="ithemes-sync-wrapper wrap">
		<?php 
        if (empty($this->options['authentications'])) {
            ?>
			<h2><?php 
            _e('Sync This Site', 'it-l10n-ithemes-sync');
            ?>
</h2>
		<?php 
        } else {
            ?>
			<h2><?php 
            _e('iThemes Sync', 'it-l10n-ithemes-sync');
            ?>
</h2>
		<?php 
        }
        ?>
		
		
		<?php 
        $this->show_messages();
        ?>
		
		
		<?php 
        if (!empty($this->options['authentications'])) {
            ?>
			<a class="ithemes-sync-button" href="<?php 
            echo $this->sync_dashboard_url;
            ?>
" target="_blank"><?php 
            _e('Go Manage Your Synced Sites', 'it-l10n-ithemes-sync');
            ?>
</a>
			
			<div class="ithemes-sync-section ithemes-sync-manage-users">
				<h3><?php 
            _e('Manage Synced Users', 'it-l10n-ithemes-sync');
            ?>
</h3>
				
				<p><?php 
            _e('Sync allows you to sync your site with multiple users.<br>View the list of synced users below, unsync users if needed, or add additional users below.', 'it-l10n-ithemes-sync');
            ?>
</p>
				
				<?php 
            if (!empty($valid_users)) {
                ?>
					<div class="ithemes-sync-users ithemes-sync-valid-users">
						<h4><?php 
                _e('Synced Users', 'it-l10n-ithemes-sync');
                ?>
</h4>
						
						<ul>
							<?php 
                foreach ($valid_users as $user_id) {
                    ?>
								<li>
									<div class="user"><?php 
                    echo $this->options['authentications'][$user_id]['username'];
                    ?>
</div>
									<div class="deauthenticate"><a href="<?php 
                    echo "{$this->self_url}&action=deauthenticate&user={$user_id}";
                    ?>
">Unsync</a>
								</li>
							<?php 
                }
                ?>
						</ul>
					</div>
				<?php 
            }
            ?>
				
				<?php 
            if (!empty($invalid_users)) {
                ?>
					<div class="ithemes-sync-users ithemes-sync-invalid-users">
						<h4><?php 
                _e('Invalid Users', 'it-l10n-ithemes-sync');
                ?>
</h4>
						
						<p><?php 
                _e('The following users were not recognized by the server. Unsync them and resync them again to fix this error.', 'it-l10n-ithemes-sync');
                ?>
</p>
						
						<ul>
							<?php 
                foreach ($invalid_users as $user_id) {
                    ?>
								<li>
									<div class="user"><?php 
                    echo $this->options['authentications'][$user_id]['username'];
                    ?>
</div>
									<div class="deauthenticate"><a href="<?php 
                    echo "{$this->self_url}&action=deauthenticate&user={$user_id}";
                    ?>
">Unsync</a>
								</li>
							<?php 
                }
                ?>
						</ul>
					</div>
				<?php 
            }
            ?>
			</div>
		<?php 
        }
        ?>
		
		
		<div class="ithemes-sync-section ithemes-sync-authorize">
			<?php 
        if (empty($this->options['authentications'])) {
            ?>
				<p><?php 
            _e('Enter your iThemes username & password to sync this site.', 'it-l10n-ithemes-sync');
            ?>
</p>
			<?php 
        } else {
            ?>
				<h3><?php 
            _e('Add Users', 'it-l10n-ithemes-sync');
            ?>
</h3>
				<p><?php 
            _e('Add additional users if more than one person will be managing updates for this site.<br>To sync an additional user, enter their iThemes username and password below.', 'it-l10n-ithemes-sync');
            ?>
</p>
			<?php 
        }
        ?>
			
			<form id="ithemes-sync-authenticate" enctype="multipart/form-data" method="post" action="<?php 
        echo $this->self_url;
        ?>
">
				<label for="username"><?php 
        _e('Username', 'it-l10n-ithemes-sync');
        ?>
</label><br>
				<input type="text" id="username" name="username" value="<?php 
        if ($this->had_error) {
            echo esc_attr($post_data['username']);
        }
        ?>
">
				
				<label for="password"><?php 
        _e('Password', 'it-l10n-ithemes-sync');
        ?>
</label><br>
				<input type="password" id="password" name="password" value="<?php 
        if ($this->had_error) {
            echo esc_attr($post_data['password']);
        }
        ?>
">
				
				<input type="submit" id="submit" value="<?php 
        _e('Sync', 'it-l10n-ithemes-sync');
        ?>
">
				<input type="hidden" name="action" value="authenticate">
				
				<?php 
        wp_nonce_field('authenticate-user');
        ?>
			</form>
		</div>
	</div>
<?php 
    }