<?php
/* 
* Theme: PREMIUMPRESS CORE FRAMEWORK FILE
* Url: www.premiumpress.com
* Author: Mark Fail
*
* THIS FILE WILL BE UPDATED WITH EVERY UPDATE
* IF YOU WANT TO MODIFY THIS FILE, CREATE A CHILD THEME
*
* http://codex.wordpress.org/Child_Themes
*/
if (!defined('THEME_VERSION')) {	header('HTTP/1.0 403 Forbidden'); exit; }

global $post, $CORE_UI, $userdata, $CORE;

   // ADMIN PREVIEW
    if(!isset($post->ID)){
		$post = new stdClass();
		$post->ID 			= 1;
		$post->post_title 	= "This is a sample title."; 
		$post->post_author 	= 1; 
		$post->post_excerpt = "";
		$post->post_content = "";
		$post->comment_count = 0;
		$post->thistheme = THEME_KEY;
		$post->storeimageset = "";
		$post->store_image = "";
		$post->carddata = "";
	}

 	$title = $post->post_title;
	$name = "";
	$found 	= wp_get_object_terms( $post->ID, 'store' );
	$store_id = "";
	$store_image = "";
	$link = "";

 
	$mainlink = $post->link;

	if(is_array($found) && !empty($found)){
		$link = get_term_link($found[0]->term_id, "store");	 
		$name = strip_tags(do_shortcode('[STORENAME]')); 
		$store_image = do_shortcode('[STOREIMAGE sid='.$found[0]->term_id.']');
		$store_id = $found[0]->term_id;

		$mainlink = $link."?__sid=".$post->ID;
	} 
	
	if(defined('WLT_DEMOMODE') && $store_image == ""){
		if(isset($_SESSION['design_preview'])){
			$store_image = DEMO_IMGS."?fw=text160&i=".rand(1,8)."&t=".THEME_KEY."&ct=".$_SESSION['design_preview'];
		}
	}

 
	
?> 

<div ppt-border2 class="position-relative rounded-10 mb-4 bg-content overflow-hidden hide-mobile" data-pid='%postid%'>

      <a href="<?php echo $post->link; ?>" style="position: relative; display: block; height:180px;" class="overflow-hidden" >
      <div class="bg-overlay-dark"> </div>
            <img src="<?php echo $post->image; ?>" class="img-fluid" alt="<?php echo $post->post_title; ?>" style="max-height:250px;" />
        </a>

        
          <div class="hide-mobile overflow-hidden text-center" style="position: absolute; left: 10px; height: 60px; width: 110px; line-height: 60px; border: 1px solid #e7edf3; box-shadow: 1px 1px 0 0 rgb(196 196 196 / 24%); bottom: 90px; background: #fff; z-index: 1;">
            <a href="<?php echo $link; ?>">
              <img src="<?php echo $store_image; ?>" class="img-fluid" alt="<?php echo $name; ?>" style="max-height:60px;" />
            </a>
          </div>
        

        <div class="p-3" ppt-flex-between>
            <div class="text-600 text-black">
            <?php echo $post->post_title; ?>
                
            </div>

            <a href="<?php echo $mainlink; ?>" class="btn btn-system" ppt-btn><?php echo __("View","premiumpress"); ?></a>
        </div>

        
</div> 

<?php

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
 
?>
<div class="show-mobile">

<div style="display:none;"><?php echo do_shortcode('[CBUTTON]'); ?></div>

  <div class="d-flex position-relative mb-3 border-bottom pb-3">
    <div class="w-100">
      <div class="fs-5 lh-30 text-700 cursor"  onclick="jQuery('.coupon-btn-<?php echo $post->ID; ?>').trigger('click');">
        <?php echo $title; ?>
      </div>
      <div class="d-flex mt-2 fs-sm align-items-center">
       
      
      <?php if(is_array($found) && !empty($found)){ ?>
        <a href="javascript:void(0);" class="btn-gocoupon" data-nextlink="<?php echo $link; ?>" data-store="1" data-couponid="<?php echo $found[0]->term_id; ?>">
        <div style="height:25px; width:50px; min-width:50px;" class="store-icon-small  mr-3">
          <div ppt-border1 class="h-100 position-relative">
            <div class="bg-image" data-bg="<?php echo $store_image; ?>">
              &nbsp;
            </div>


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

        
        <div>
          <div class="d-inline-flex verified text-success text-600 mr-2">
            <div ppt-icon-16 data-ppt-icon-size="16">
              <?php echo $CORE_UI->icons_svg['check_circle']; ?>
            </div>
            <div class="ml-1">
              <?php echo __("Verified","premiumpress"); ?>
            </div>
          </div>
        </div>
        <div class="">
          <?php echo do_shortcode('[TIMELEFT textonly=1]'); ?>
        </div>
      </div>
    </div>
  </div>
</div>

</div>
