<?php
defined('ABSPATH') || exit('No Access!');

$header_menu_custom_items = $options->get_option('header-menu-custom-items');
$header_menu_custom_items = is_array($header_menu_custom_items) ? $header_menu_custom_items : [];
$account_ads_image = $options->get_option('account-ads-image');
$menus = get_registered_nav_menus();
?>
<div class="irk-settings-area irk-settings-user-control">
    <h2 class="irk-settings-title">
        <span class="irk-title-icon"><span uk-icon="user"></span></span>
        <strong><?php _e('User control', 'irk'); ?></strong>
    </h2>
    <div class="uk-margin">
        <label class="uk-form-label" for="irk-account-url"><?php _e('Account URL', 'irk'); ?></label>
        <input type="text" class="uk-input" id="irk-account-url" name="account-url" value="<?php echo esc_attr($options->get_option('account-url')); ?>">
    </div>
    <div class="uk-margin">
        <label class="uk-form-label" for="irk-login-url"><?php _e('Login URL', 'irk'); ?></label>
        <input type="text" class="uk-input" id="irk-login-url" name="login-url" value="<?php echo esc_attr($options->get_option('login-url')); ?>">
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Account menu items', 'irk'); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-menu-items" value="1" <?php checked($options->get_option('account-menu-items'), 1); ?>>
                <?php _e('Show account menu items in header', 'irk'); ?>
            </label>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Header menu custom items', 'irk'); ?></label>
        <div>
            <?php if (count($header_menu_custom_items)): ?>
                <?php foreach ($header_menu_custom_items as $item): ?>
                    <div class="uk-margin-small">
                        <input type="text" class="uk-input" name="header-menu-custom-items[]" value="<?php echo esc_attr($item); ?>" placeholder="<?php _e('Title:URL', 'irk'); ?>">
                    </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
        <a href="#" class="irk-new-custom-item uk-button uk-button-default uk-button-small"><?php _e('New item', 'irk'); ?></a>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label" for="irk-redirect-login"><?php _e('Redirect URL after login', 'irk'); ?></label>
        <input type="text" class="uk-input" id="irk-redirect-login" name="redirect-login" value="<?php echo esc_attr($options->get_option('redirect-login')); ?>">
    </div>
    <div class="uk-margin">
        <label class="uk-form-label" for="irk-redirect-register"><?php _e('Redirect URL after register', 'irk'); ?></label>
        <input type="text" class="uk-input" id="irk-redirect-register" name="redirect-register" value="<?php echo esc_attr($options->get_option('redirect-register')); ?>">
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Google auth', 'irk'); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="google-auth" value="1" <?php echo checked($options->get_option('google-auth'), 1); ?>>
                <?php _e('Active', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <input type="text" class="uk-input" name="google-id" value="<?php echo esc_attr($options->get_option('google-id')); ?>" placeholder="<?php _e('Client ID', 'irk'); ?>">
        </div>
        <div class="uk-margin-small">
            <input type="text" class="uk-input" name="google-secret" value="<?php echo esc_attr($options->get_option('google-secret')); ?>" placeholder="<?php _e('Client secret', 'irk'); ?>">
        </div>
        <div class="irk-description">
            <span uk-icon="info"></span>
            <a href="https://console.developers.google.com" target="_blank"><?php _e('Get from this link.', 'irk'); ?></a>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Account advertisement', 'irk'); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-ads" value="1" <?php echo checked($options->get_option('account-ads'), 1); ?>>
                <?php _e('Active', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <div class="irk-upload-file-wrapper">
                <img src="<?php echo intval($account_ads_image) ? wp_get_attachment_url($account_ads_image) : IRK_IMG_URI . 'dot.png'; ?>" class="irk-image" alt="image">
                <input type="hidden" name="account-ads-image" value="<?php echo esc_attr($account_ads_image); ?>">
                <br>
                <button class="uk-button uk-button-primary irk-upload-file"><?php _e('Select image', 'irk'); ?></button>
                <button class="uk-button uk-button-default irk-remove" data-default="<?php echo IRK_IMG_URI . 'dot.png'; ?>"><?php _e('Remove image', 'irk'); ?></button>
            </div>
        </div>
        <div class="uk-margin-small">
            <input type="text" class="uk-input" name="account-ads-url" value="<?php echo esc_attr($options->get_option('account-ads-url')); ?>" placeholder="<?php _e('URL', 'irk'); ?>">
        </div>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-ads-target" value="1" <?php echo checked($options->get_option('account-ads-target'), 1); ?>>
                <?php _e('Open link in new tab', 'irk'); ?>
            </label>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Account items', 'irk'); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-notifications" value="1" <?php checked($options->get_option('account-notifications'), 1); ?>>
                <?php _e('Notifications', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-viewed-products" value="1" <?php checked($options->get_option('account-viewed-products'), 1); ?>>
                <?php _e('Viewed products', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-comments" value="1" <?php checked($options->get_option('account-comments'), 1); ?>>
                <?php _e('Comments', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-favorites" value="1" <?php checked($options->get_option('account-favorites'), 1); ?>>
                <?php _e('Favorites', 'irk'); ?>
            </label>
        </div>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="account-avatar" value="1" <?php checked($options->get_option('account-avatar'), 1); ?>>
                <?php _e('Avatar', 'irk'); ?>
            </label>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Password strength', 'irk'); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="password-strength" value="1" <?php checked($options->get_option('password-strength'), 1); ?>>
                <?php _e('Disable', 'irk'); ?>
            </label>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e('Login footer menu', 'irk'); ?></label>
        <div uk-form-custom="target: > * > span:first-child">
            <select name="login-footer-menu">
                <option value=""><?php _e('None', 'irk'); ?></option>
                <?php if (count($menus)): ?>
                    <?php foreach ($menus as $key => $value): ?>
                        <option value="<?php echo $key; ?>"><?php echo esc_html($value); ?></option>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
            <button class="uk-button uk-button-default" type="button" tabindex="-1">
                <span></span>
                <span uk-icon="icon: chevron-down"></span>
            </button>
        </div>
    </div>
</div>