<?php
/**
 * @package WordPress
 * @subpackage Yoko
 */
//** Ak new TAW Player stuff: START FROM OLD SITE **//
	$audio = get_post_meta(get_the_ID(),'podcast-audio-file',true);
	$tawclass = "";
	if (strlen($audio)>0) {
	}else{
		$audio = get_post_meta(get_the_ID(),'enclosure',true);
		if (strlen($audio)>0) {
			$audio = explode("\n",$audio);
			$audio = $audio[0];
		}
	}
	if (strlen($audio)>0) {
		$tawclass = " taw-player show-player";
		$showplayer = 1;
		$AUDIOplayer = '<audio src="'.$audio.'" type="audio/mp3" controls="controls"></audio>';
		$AUDIOdlink = "";
#		if (strpos($audio,'/subscription/content/') !== false) { // test, using amember/aws file protection
		if (strpos($audio,'amazonaws.com/taw-player-audio/') !== false) {
		// amember protected audio
			if (Am_Lite::getInstance()->haveSubscriptions(1)) {
			
			 
#				$AUDIOdlink = '<p class="taw-player-dl"><a href="'.$audio.'">Direct Link: '.get_the_title().'</a></p>';
				$AUDIOdlink = '<p class="taw-player-dl"><a href="/taw-player/instructions">TAW Player download / RSS feed instructions</a></p>';
			}else{
				$tawclass = " taw-player";
				$showplayer = 2;
				
				  
			}
		}
	}
	if ($showplayer == 1) {
		$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id(), 'medium');
		if (strlen($imgsrc[0]) > 0) $imgsrc = ' style="background-image:url(\''.$imgsrc[0].'\');"';
		else $imgsrc = "";
		
		$showtitle = get_post_meta(get_the_ID(),'podcast-show-name',true);
		if (strlen($showtitle)>0) {
			$identsrc = get_template_directory()."/images/id-".strtolower(str_replace(' ','-',$showtitle)).".png";
			if (file_exists($identsrc)) {
				$identsrc = get_template_directory_uri()."/images/id-".strtolower(str_replace(' ','-',$showtitle)).".png";
				$identsrc = '<span class="ident" style="background-image:url(\''.$identsrc.'\');"></span>';
				$tawclass.= " show-ident";
			}else{
				$identsrc = "";
			}
		}
	}
/* END FROM OLD SITE */


?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <header class="entry-header">

       <?php if ( option::is_on( 'post_category' ) ) { ?><span class="cat-links"><?php the_category( ', ' ); ?></span><?php } ?>

        <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>


        <div class="post-meta">

            <?php if ( option::is_on( 'post_date' ) ) { ?>
                <time class="entry-date published updated" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>">
                    <?php echo get_the_date(); ?> <?php echo get_the_time(); ?>
                </time>
            <?php } ?>


            <?php if ( option::is_on( 'post_author' ) )  {

                printf( '<span class="entry-author vcard author">%1$s <a class="url fn n" href="%2$s">%3$s</a></span>',
                    __( 'by ', 'wpzoom' ),
                    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                    get_the_author()
                );

            } ?>

            <?php edit_post_link( __('Edit this post', 'wpzoom'), '<span class="separator">&middot;</span> ', '');

            if (option::get('post_views') == 'on') { ?><span class="views"><?php _e('Views', 'wpzoom'); ?>: <?php printf( get_post_meta( get_the_ID(), 'Views', true ) );  ?></span><?php }
            ?>

        </div>


    </header><!-- .entry-header -->

    <div class="clear"></div>

    <div class="entry-content">

        <?php if ( option::is_on('banner_before_post_enable')  ) { // Banner after post ?>

             <div class="adv_content">
             <?php
                 if ( option::get('banner_before_post_html') <> "" ) {
                     //echo stripslashes(option::get('banner_before_post_html'));
                    
     					
     					///insert Matt device detection code: 
    				



 						if ( wp_is_mobile() ) {
 							/* Display and echo mobile specific stuff here */
	
 						?>
 						<!--JavaScript Tag with group ID // Tag for network 1639: Snack Media  // Website: theanfieldwrap.com // Page: theanfieldwrap.com ROS // Placement: theanfieldwrap.com Mobile Leaderboard (6301073) // created at: Aug 22, 2016 3:29:42 PM-->
 						<script language="javascript">
 						<!--
 						if (window.adgroupid == undefined) {
 							window.adgroupid = Math.round(Math.random() * 1000);
 						}
 						document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/1639/6301073/0/3055/ADTECH;loc=100;target=_blank;grp='+window.adgroupid+';misc='+new Date().getTime()+'"></scri'+'pt>');
 						//-->
 						</script><noscript><a href="http://adserver.adtech.de/adlink/3.0/1639/6301073/0/3055/ADTECH;loc=300" target="_blank"><img src="http://adserver.adtech.de/adserv/3.0/1639/6301073/0/3055/ADTECH;loc=300" border="0" width="320" height="50"></a></noscript>
 						<!-- End of JavaScript Tag -->
 						<?php	
	
	
	
	

	


 						}//end of if

 						else {
	
 						?>
 						<!--JavaScript Tag with group ID // Tag for network 1639: Snack Media  // Website: theanfieldwrap.com // Page: theanfieldwrap.com ROS // Placement: theanfieldwrap.com Leaderboard (6301074) // created at: Aug 22, 2016 3:29:42 PM-->
 						<script language="javascript">
 						<!--
 						if (window.adgroupid == undefined) {
 							window.adgroupid = Math.round(Math.random() * 1000);
 						}
 						document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/1639/6301074/0/225/ADTECH;loc=100;target=_blank;grp='+window.adgroupid+';misc='+new Date().getTime()+'"></scri'+'pt>');
 						//-->
 						</script><noscript><a href="http://adserver.adtech.de/adlink/3.0/1639/6301074/0/225/ADTECH;loc=300" target="_blank"><img src="http://adserver.adtech.de/adserv/3.0/1639/6301074/0/225/ADTECH;loc=300" border="0" width="728" height="90"></a></noscript>
 						<!-- End of JavaScript Tag -->
 						<?php
 	/* Display non mobile ads here */
 }
					
     					///end Matt device detection code                   
                    
                    
                    
                   
                 } else {
                     ?><a href="<?php echo option::get('banner_before_post_url'); ?>"><img src="<?php echo option::get('banner_before_post'); ?>" alt="<?php echo option::get('banner_before_post_alt'); ?>" /></a><?php
                 }

             ?></div><?php
         } ?>

        <?php /* !!! THIS IS WHERE THE CONTENT STARTS !!! echo("testCONTENT!!!!"); */?>
        
        
        
        
        
        
        
        <?php /* START AUDIO CODE HERE */ ?>
        
        <?php
		///show player if audio file exists. Needs to have a further check inside that checks if user is a sub or not
	if (strlen($audio)>0 && $showplayer == 1) {
?>



<?php
//if not logged in, show audioboom player: 
if (!Am_Lite::getInstance()->isLoggedIn()) {
	$onlyShowFree = true;
	
	//get post title
	$mattGetTitle = get_the_title();
	
	// if post title contains the word 'free' or 'rider': 
	if (strpos($mattGetTitle,'Free') !== false || strpos($mattGetTitle,'Rider') !== false){
		?>
		<iframe width="100%" height="350" style="background-color:transparent; display:block; max-width: 700px;" frameborder="0" allowtransparency="allowtransparency" scrolling="no" src="//embeds.audioboom.com/publishing/playlist/v4?bg_fill_col=%23ecefef&amp;boo_content_type=channel&amp;data_for_content_type=2402227&amp;image_option=small&amp;link_color=%2358d1eb&amp;player_theme=light&amp;src=https%3A%2F%2Fapi.audioboom.com%2Fchannels%2F2402227%2Faudio_clips%3Finclude_child_channels%3D1" title="audioBoom player"></iframe>
		
<?php		
	} //end of if
	

	
	?>


	
	<?php
	
}

?>


<?php
/// if audioboom has already been show, $onlyShowFree will be set to true and won't show other player:
if ($onlyShowFree != true){ 
?>
<div class="taw-audio-player"><span class="audio"<?php echo $imgsrc; ?>><?php echo $AUDIOplayer; ?></span><?php echo $identsrc; ?></div>

<?php
}
?>



<?php
	}
?>
	<div class="single-entry-content<?php echo $tawclass; ?>">
<?php
	if ($showplayer == 2) {
			if ($user = Am_Lite::getInstance()->getUsername()) {
				echo "<p>Logged in as <strong>$user</strong> <a href=\"/subscription/logout\">Logout</a></p>";
    			//echo '<p>TAW subscription required for this podcast, <a href="/subscription/signup">Subscribe&nbsp;Here</a></p>'."\n";
			}else{
?>
	<div class="taw-player-login">
    	<p>TAW subscription required for this podcast, if you are a subscriber login below or&nbsp;<a href="/subscription/signup">Subscribe&nbsp;Here</a></p>
            <form name="loginform" id="loginform" action="/subscription/login" method="POST">
                <p><label>E-Mail Address or Username</label><br/>
                    <input type="text" name="amember_login" class="input" id="user_login" size="15"></p>
                <p><label>Password</label><br/>
                <input type="password" name="amember_pass" id="user_password" class="input" size="15"></p>
                                <input type="hidden" name="amember_redirect_url" value="<?php echo $_SERVER["REQUEST_URI"]; ?>">
                                <p class="submit">
                    <input type="submit" name="wp-submit" id="wp-submit" value="Login">
                </p>
            </form>
            <p><a href="/subscription/login?amember_redirect_url=<?php echo $_SERVER["REQUEST_URI"]; ?>">Lost Password</a></p>
	</div>
<?php
			}
	}
?>
            <?php echo $AUDIOdlink; ?>
            

        <?php /* END AUDIO CODE HERE */ ?>
        
        
        
        
        
        
        
        
        
        <?php the_content(); ?>
        
        

        <div class="clear"></div>

        <?php if ( option::is_on('banner_post_enable')  ) { // Banner after post ?>

            <div class="adv_content">
            
            
            
            <?php
                if ( option::get('banner_post_html') <> "" ) {
                    //echo stripslashes(option::get('banner_post_html'));
                    
                        					
    					///insert Matt device detection code: 
    				



if ( wp_is_mobile() ) {
	/* Display and echo mobile specific stuff here */
	?>
	
	<!--JavaScript Tag with group ID // Tag for network 1639: Snack Media  // Website: theanfieldwrap.com // Page: theanfieldwrap.com ROS // Placement: theanfieldwrap.com Mobile MPU Middle (6301080) // created at: Aug 22, 2016 3:29:43 PM-->
	<script language="javascript">
	<!--
	if (window.adgroupid == undefined) {
		window.adgroupid = Math.round(Math.random() * 1000);
	}
	document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/1639/6301080/0/170/ADTECH;loc=100;target=_blank;grp='+window.adgroupid+';misc='+new Date().getTime()+'"></scri'+'pt>');
	//-->
	</script><noscript><a href="http://adserver.adtech.de/adlink/3.0/1639/6301080/0/170/ADTECH;loc=300" target="_blank"><img src="http://adserver.adtech.de/adserv/3.0/1639/6301080/0/170/ADTECH;loc=300" border="0" width="300" height="250"></a></noscript>
	<!-- End of JavaScript Tag -->
	<?php
}

else {
	?>
	<!--JavaScript Tag with group ID // Tag for network 1639: Snack Media  // Website: theanfieldwrap.com // Page: theanfieldwrap.com ROS // Placement: theanfieldwrap.com MPU (6301082) // created at: Aug 22, 2016 3:29:43 PM-->
	<script language="javascript">
	<!--
	if (window.adgroupid == undefined) {
		window.adgroupid = Math.round(Math.random() * 1000);
	}
	document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/1639/6301082/0/170/ADTECH;loc=100;target=_blank;grp='+window.adgroupid+';misc='+new Date().getTime()+'"></scri'+'pt>');
	//-->
	</script><noscript><a href="http://adserver.adtech.de/adlink/3.0/1639/6301082/0/170/ADTECH;loc=300" target="_blank"><img src="http://adserver.adtech.de/adserv/3.0/1639/6301082/0/170/ADTECH;loc=300" border="0" width="300" height="250"></a></noscript>
	<!-- End of JavaScript Tag -->
	<?php

	/* Display non mobile ads here */
}
					
    					///end Matt device detection code
                    
                    
                } else {
                    ?><a href="<?php echo option::get('banner_post_url'); ?>"><img src="<?php echo option::get('banner_post'); ?>" alt="<?php echo option::get('banner_post_alt'); ?>" /></a><?php
                }

            ?>
            
            
            
            </div><?php
        } ?>

    </div><!-- .entry-content -->


    <footer class="entry-footer">

        <?php
            wp_link_pages( array(
                'before' => '<div class="page-links">' . __( 'Pages:', 'wpzoom' ),
                'after'  => '</div>',
            ) );
        ?>

        <?php if (option::get('post_tags') == 'on') { ?><?php the_tags( '<div class="tag_list">'. __('Tags:', 'wpzoom'). ' ',', ', '</div>'); ?><?php } ?>


        <?php if ( option::is_on( 'post_author_box' ) ) : ?>

            <div class="post_author vcard">

                <?php echo get_avatar( get_the_author_meta('ID') , 70 ); ?>

                <div class="author-description">

                    <?php printf( '<span>%1$s <a class="url fn n" href="%2$s">%3$s</a></span>',
                        __( 'Author: ', 'wpzoom' ),
                        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                        get_the_author()
                    );

                    the_author_meta( 'description' );
                    ?>

                </div>

                <div class="clear"></div>
            </div>

        <?php endif; ?>

    </footer><!-- .entry-footer -->

</article><!-- #post -->
