<?php

class core_classifieds extends white_label_themes {

	function __construct(){ global $wpdb;
	
	// ADD SHORTCODE
	add_shortcode( 'CONTACTBAR', array($this,'shortcode_contactbar') );
	
	// ADD SHORTCODE
	add_shortcode( 'CT_IMAGEBLOCK', array($this,'shortcode_imageblock') );
	
	}// end function
	
	
	
	
function shortcode_imageblock(){ global $CORE, $MEDIA, $post, $userdata;

// GET PRICE
$price = get_post_meta($post->ID, 'price', true);
if($price == ""){ $price = ""; }else{ $price = hook_price($price); }

// DESCRIPTION
$dee = get_the_author_meta( 'description', $post->post_auhtor);

// IMAGES
$images = $MEDIA->_GET($post->ID, "images"); 
 

// PHONE
$phone = get_user_meta($post->post_author,'phone', true);
	
ob_start();

?>

<div class="shortcode_imageblock">
    <div class="row">
        <div class="col-md-4 col-sm-12">
            <div class="shortcode_imageblock-title" >
 
<div class="text-center price"><?php echo $price; ?></div>


<?php if(strlen($phone) > 1){ ?>
<h2 class="text-center phone"><i class="fa fa-phone"></i> <?php echo $phone; ?></h2>
<?php } ?>

<?php  if(strlen($dee) > 1){ ?>
        
<hr /> <div class="userdesc"><?php echo wpautop($dee); ?></div> 
        <script>
            jQuery(document).ready(function(){
                jQuery('.userdesc').shorten({
                    moreText: '<?php echo $CORE->_e(array('feedback','3')); ?>',
                    lessText: '<?php echo $CORE->_e(array('feedback','4')); ?>',
                    showChars: '155',
                });
            });
            </script>
<?php } ?> 



<hr />
<?php echo do_shortcode("[CONTACT button=1 class='btn btn-lg btn-success active' text='".$CORE->_e(array('class','3'))."']"); ?>

<div class="text-center small"><?php echo $CORE->_e(array('class','1')); ?> #<?php echo $post->ID; ?></div>



      </div>
        
        </div>
        <div class="col-md-8 col-sm-12">
        
<ul class="list-unstyled list-inline">

 
<?php

$i=1;
if(is_array($images) && !empty($images) ){

	if(count($images) == 1){ $extracss = "class='justoneimg'"; $type = "src"; }else{ $extracss = ""; $type = "thumbnail"; }
			 
		foreach($images as $img){ 
		
			// ADD THE ARRAY TO MEDIA SET
			$MEDIA->media_set = array_merge($MEDIA->media_set, array($img['id']));
		 
			echo "<li ".$extracss."><a href='".$img['src']."' data-gal='prettyPhoto[pp_gal]'><img src='".$img[$type]."' class='pimg".$i."'></a></li>";
			$i++;
		
		}			  
}


?>

</ul>

 
		</div>

    </div>
    
</div>
 

<?php 
return ob_get_clean(); 
}
 	
	
function shortcode_contactbar(){ global $post, $CORE, $userdata;


if($GLOBALS['CORE_THEME']['show_account_social'] != 1){ return; }

// GET USER OPTIONS
if($userdata->ID){
$data1 = "href='".get_user_meta( $post->post_author, 'facebook', true)."'";
$data2 = "href='".get_user_meta( $post->post_author, 'twitter', true)."'"; 
$data3 = "href='".get_user_meta( $post->post_author, 'linkedin', true)."'";
$data4 = "href='".get_user_meta( $post->post_author, 'skype', true)."'";
}else{
$data1 = "href='javascript:(0);' onclick=\"alert('".$CORE->_e(array('checkout','53'))."')\" ";
$data2 = "href='javascript:(0);' onclick=\"alert('".$CORE->_e(array('checkout','53'))."')\" ";
$data3 = "href='javascript:(0);' onclick=\"alert('".$CORE->_e(array('checkout','53'))."')\" ";
$data4 = "href='javascript:(0);' onclick=\"alert('".$CORE->_e(array('checkout','53'))."')\" ";
}
ob_start();

?>
 
<div class="text-center"><h3><?php echo $CORE->_e(array('class','2')); ?></h3></div>

<hr />

<div class="linkbar row clearfix">
   
            <?php 
 
            // FACEBOOK           
            if(strlen($data1) > 0){ 
            echo "<div class='col-md-3 col-sm-6 fb'><div class='wrap'> <a ".$data1." rel='nofollow' target='_blank'><i class='fa fa-facebook-square'></i> Facebook</a></div></div>"; 
            }  	
            
            // TWITTER            
            if(strlen($data2) > 0){ 
            echo "<div class='col-md-3 col-sm-6 tw'><div class='wrap'> <a href='".$data2."' rel='nofollow' target='_blank'> <i class='fa fa-twitter-square'></i> Twitter</a></div></div> "; 
            }  		
            
            // LINKEDIN            
            if(strlen($data3) > 0){ 
            echo "<div class='col-md-3 col-sm-6 in'><div class='wrap'><a href='".$data3."' rel='nofollow' target='_blank'><i class='fa fa-linkedin-square'></i>  Linkedin</a></div></div>"; 
            } 	
    
            // SKYPE            
            if(strlen($data4) > 0){ 
            echo "<div class='col-md-3 col-sm-6 sk'><div class='wrap'><a href='skype:".$data4."' rel='nofollow' target='_blank'><i class='fa fa-skype'></i> Skype</a></div></div>"; 
            }
            
            ?>

</div>

<?php

return ob_get_clean(); 
}

}

?>