<?php
global $redux_demo;
$localvideo = get_post_meta($post->ID, '_video_localvideo', true);
$externalvideo = get_post_meta($post->ID, '_video_externalvideo', true);
$nsfw = get_post_meta($post->ID, '_video_nsfw', true);
if(is_user_logged_in() ) {
    $userid = wp_get_current_user();
    if(get_user_meta($userid->ID, '_nsfw', true) != 1) {
        $nsfw = 2;
    }
}
$class = 'main-post';
if(is_single() ) {
    $class .= ' post-page';
}
?>
<article <?php post_class($class);?>>
    <?php get_template_part('content', 'header');?>
    <div class="article-content">
        <?php get_template_part('content', 'infobar');?>
        <figure <?php if($nsfw == 1) echo 'class="nsfw"';?>>
            <?php $categories = get_the_category();
            if(count($categories) > 0) { ?>
                <div class="corner-tag yellow">
                    <?php
                    for($i=0; $i<count($categories); $i++) {
                        echo '<a href="' . get_category_link($categories[$i]->term_id)  . '">' . $categories[$i]->name . '</a>';
                        if($i != count($categories) -1)
                            echo '&nbsp; | &nbsp; ';
                        echo PHP_EOL;
                    } ?>
                </div>
            <?php } 
            if( (isset($externalvideo) && $externalvideo != '') || (isset($localvideo) && $localvideo != '') ) { ?>
                <div class="video-wrap">
                    <?php 
                    if(isset($externalvideo) && $externalvideo != '') {
                        if(isset($GLOBALS['wp_embed'])) {
                            $embed = $GLOBALS['wp_embed']->autoembed($externalvideo);
                            $embed = str_replace("feature=oembed", "feature=oembed&amp;wmode=transparent", $embed);
                            echo $embed;
                        }
                    }
                    elseif(isset($localvideo) && $localvideo != '') { 
                        echo apply_filters('the_content', '[video width="650" height="360" src="' . $localvideo . '"]');
                    }
                    ?>
                </div> 
            <?php } ?>
            <div class="nsfw_text"><?php _e('Not safe for work', 'Aruna');?></div>
            <div class="nsfw_textreveal"><?php _e('Click here to reveal', 'Aruna');?></div>
        </figure>
    </div>
</article>