<?php 
get_header();
global $current_user; get_currentuserinfo();
$id = $current_user->ID;
$bg = get_user_meta($id, '_cover', true);
$avatar = get_user_meta($id, '_avatar', true);
$nsfw = get_user_meta($id, '_nsfw', true);
if($bg == '') {
    $bg = get_template_directory_uri() . '/img/user-cover02.jpg';
}
if(isset($_GET['error']) ) { 
    $error = esc_html(stripslashes(urldecode($_GET['error']) ) );
}
if(isset($_GET['success']) ) {
    $success = 1;
}
?>
<section id="main" role="main">
    <div class="container">
        <div class="row">
            <div class="col-sm-9 right-content profile-bg">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="main-wrap">
                            <h1><?php _e('PUBLIC PROFILE & ACCOUNT', 'Aruna');?></h1>
                            <div class="separator"></div>
                            <form enctype="multipart/form-data" action="" method="post">
                                <div class="user-cover-edit" style="background-image: url('<?php echo $bg;?>');">
                                    <div class="col-sm-9 col-md-9">
                                        <div class="outer">
                                            <div class="inner">
                                                <figure>
                                                    <?php echo teo_get_avatar($current_user->ID, 90, 90);?>
                                                </figure>
                                                <div class="text">
                                                    <div class="outer">
                                                        <div class="inner">
                                                            <a href="#" class="user-name"><?php echo $current_user->display_name;?></a>
                                                            <div class="page-name"><?php _e('Settings page', 'Aruna');?></div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 col-md-3">
                                        <div class="outer">
                                            <div class="inner">
                                                <?php
                                                $kudos = teo_get_kudos();
                                                if($kudos > 1000) {
                                                    $kudos = ($kudos/1000) . 'k';
                                                }
                                                ?>
                                                <div class="counter-item">
                                                    <span class="number"><?php echo $kudos;?></span><br>
                                                    <span class="exp"><?php _e('kudos', 'Aruna');?></span>
                                                </div>
                                                <div class="counter-item">
                                                    <span class="number"><?php echo count_user_posts($current_user->ID);?></span><br>
                                                    <span class="exp"><?php _e('posts', 'Aruna');?></span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <?php if(isset($error) || isset($success) ) { ?>
                                    <div class="row">
                                        <div class="col-sm-10">
                                            <?php if(isset($success) && $success != '') { ?>
                                                <div class="alert alert-success">
                                                    <?php _e('Profile edited successfully', 'Aruna');?>
                                                </div>
                                            <?php } elseif($error != '') { ?>
                                                <div class="alert alert-danger">
                                                    <?php echo $error;?>
                                                </div>
                                            <?php } ?>
                                        </div>
                                    </div>
                                <?php } ?>
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group">
                                            <span class="input-group-addon"><?php _e('Email:', 'Aruna');?></span>
                                            <input name="email" type="text" class="form-control" value="<?php echo $current_user->user_email;?>">
                                        </div>
                                        <div class="input-group">
                                            <span class="input-group-addon"><?php _e('New Password:', 'Aruna');?></span>
                                            <input name="password" type="password" class="form-control" value="" placeholder='<?php _e("Only if you want to change it", "Aruna");?>'>
                                        </div>
                                    </div>
                                    <div class="col-sm-5">
                                        <div class="input-group">
                                            <span class="input-group-addon"><?php _e('Display name:', 'Aruna');?></span>
                                            <input name="display" type="text" class="form-control" value="<?php echo $current_user->display_name;?>">
                                        </div>
                                        <div class="input-group">
                                            <span class="input-group-addon"><?php _e('Repeat Password:', 'Aruna');?></span>
                                            <input name="password2" type="password" class="form-control" value="" placeholder="<?php _e('(if applicable)', 'Aruna');?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group ">
                                            <span class="input-group-addon"><?php _e('Background img:', 'Aruna');?></span>
                                            <input type="text" readOnly class="form-control" value="<?php echo $bg;?>" placeholder="The url of the background image">
                                        </div>
                                    </div>
                                    <div class="col-sm-5 profilebgedit">
                                        <input name="cover" type="file" />
                                    </div>
                                </div> 
                                <div class="row">
                                    <div class="col-sm-5">
                                        <div class="input-group ">
                                            <span class="input-group-addon"><?php _e('Avatar image:', 'Aruna');?></span>
                                            <input type="text" readOnly class="form-control" value="<?php echo $avatar;?>" placeholder="The url of the avatar image">
                                        </div>
                                    </div>
                                    <div class="col-sm-5 profilebgedit">
                                        <input name="avatar" type="file" />
                                    </div>
                                </div> 
                                <h1><?php _e('Preferences', 'Aruna');?></h1>
                                <div class="separator"></div>
                                <div class="checkbox-line">
                                    <div class="custom-checkbox">
                                        <input type="checkbox" value="check1" name="nsfw" id="check2" <?php if(isset($nsfw) && $nsfw == 1) echo 'checked="checked"';?> />
                                        <label for="check2" class="has-popover" data-content="If you want to see the 'Not safe for work' posts, enable it!"><?php _e('ADULT FILTER', 'Aruna');?></label>
                                    </div>
                                </div>
                                <div style="clear: both"></div><br />
                                <div class="row">
                                    <div class="col-sm-5">
                                        <button name="editprofile" class="btn btn-primary custom-button btn-block" type="submit"><i class="glyphicon glyphicon-check"></i> <?php _e('Save Settings', 'Aruna');?></button>
                                        <div class="spacer"></div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <?php get_sidebar('left');?>
        </div>
    </div>
</section>
<!-- www.20script.ir -->
<?php get_footer();?>