<?php 

if ( ! defined( 'ABSPATH' ) ) {

          header( 'Status: 403 Forbidden' );

          header( 'HTTP/1.1 403 Forbidden' );

         exit;

      } // Exit if accessed directly

function gd_coupon_box_display($atts){

$gd_coupon_box_count=$atts['box'];

$gd_coupon_box_ids=$atts['id'];

if(!empty($gd_coupon_box_ids)){

	$post_in='p';

$post_value = $gd_coupon_box_ids;

	}else{

$post_in='posts_per_page';

$post_value =$gd_coupon_box_count;

}

$args = array(

$post_in=>$post_value,

'post_type'=>'greedycoupon',

'post_status'=>'publish',

'order'=>'DSC'

);

query_posts( $args );

// The Loop

while ( have_posts() ) : the_post();

 global $post;

// The Query

$the_query = new WP_Query( $args );

//Review Post Meta Value

$rzilla_hosting_name=get_post_meta($post->ID, 'rzilla_hosting_name', true);

$output='

 <div class="review_box_out">

  <div class="review_box" style="height: inherit;padding: 0px;">

   <div style="width:100%;max-height: 100px;height: 90px;overflow:hidden"> <img style="border:0px;background-color:transparent;margin:0px 10px;padding: 10px;width: 90%;" src="'.the_post_thumbnail_url('medium').'"> </div>

   <div align="center">

    <div class="rz-review-rating-circle">

     <meta itemprop="bestRating" content="10"/>

     <div class="rz-review-rating" itemprop="ratingValue"> '.$overall_rating.' </div>

     <div class="rz-review-badge"> '.$overall_rating_stars.' </div>

    </div>

    <span class="rz-review" style="height: 50px;"> <span class="rz-review-rating-text">Overall Rating</span> </span> </div>

   <div style="float: left;width: 100%;text-align: -webkit-center;border-bottom: 200px solid #333;border-left:0px" class="rz-review-features-rating"> </div>

   <div  style="background-color: #333;padding: 10px;"><a href="'.the_permalink().'" class="btn btn-large red">Read Review <i class="fa fa-arrow-circle-right"></i></a></div>

  </div>

 </div>'; 

endwhile;

// Reset Query

wp_reset_query();

return $output;

}

add_shortcode('gd_coupon_box','gd_coupon_box_display');

// COUPON Button Box

add_shortcode('gd_coupon_button','gd_coupon_button_display'); // Shortcode
function gd_coupon_button_display($attrs){
$gd_coupon_link=$attrs['link'];
$gd_coupon_code=$attrs['code'];
$gd_short_coupon=substr($gd_coupon_code, 0, 3);
$gd_coupon_desc=$attrs['desc'];
$gd_coupon_theme=$attrs['theme'];
$page_link=get_permalink();
if(($gd_coupon_theme=='button-box')||(!empty($gd_coupon_desc))){
if(!empty($gd_coupon_link)){
$output='<div class="coupon-btn-box">
  <div class="coupon-btn-detail coupon-button-type aff_btn">
  <h2>'.$gd_coupon_desc.'</h2>
  <a id="aff_link_'.$gd_coupon_code.'" href="#" class="coupon-button coupon-code"> <span class="code-text"> Coupon...'.$gd_short_coupon.' </span> <span class="get-code">Get Code</span> </a>
   <script type="text/javascript">
  document.getElementById("aff_link_'.$gd_coupon_code.'").onclick = function(){
   window.open("'.$gd_coupon_link.'",\'_parent\');
 window.open("'.$page_link.'#'.$gd_coupon_code.'",\'_blank\');
 }
</script>
   <div id="'.$gd_coupon_code.'" class="shp_overlay">
    <div id="shp_popup" class="shp_popup"> <a class="close" href="#">×</a>
     <h2>Here Is the Coupon Code</h2>
     <div class="gd_coupon_popup">
      <div align="center" class="">
       <div class="gd_coupon_code"> <span> '.$gd_coupon_code.' </span> </div>
       <p>Coupon Code Only Valid till the given Date/Time</p>
     </div>
    </div>
   </div>
   </div>
  </div>
</div>';
}
}elseif($gd_coupon_theme=='button-only'){
$output='<div class="coupon-btn-detail coupon-button-type aff_btn">
  <a id="aff_link_'.$gd_coupon_code.'" href="#" class="coupon-button coupon-code"> <span class="code-text"> Coupon...'.$gd_short_coupon.' </span> <span class="get-code">Get Code</span> </a>
   <script type="text/javascript">
  document.getElementById("aff_link_'.$gd_coupon_code.'").onclick = function(){
   window.open("'.$gd_coupon_link.'",\'_parent\');
 window.open("'.$page_link.'#'.$gd_coupon_code.'",\'_blank\');
 }
</script>
   <div id="'.$gd_coupon_code.'" class="shp_overlay">
    <div id="shp_popup" class="shp_popup"> <a class="close" href="#">×</a>
     <h2>Here Is the Coupon Code</h2>
     <div class="gd_coupon_popup">
      <div align="center" class="">
       <div class="gd_coupon_code"> <span> '.$gd_coupon_code.' </span> </div>
       <p>Coupon Code Only Valid till the given Date/Time</p>
     </div>
   </div>
  </div>
  </div>
</div>';	
}
return $output; }?>