<?php get_header(); ?>
<?php global $qaleb;?>
<section class="ap_main">
<div class="container inn">
<div class="ap_news">

<?php if($qaleb['ads-post-top']=='1'){?><div class="jmb_banner"><?php echo $qaleb['ads-post-top-html'];?></div><?php } ?>

<div class="content">
<header class="heding">
<?php if($qaleb['singl-like-ac']=='1'){?><div class="post_like"><?php echo get_simple_likes_button(get_the_ID()); ?></div><?php } ?>
<?php if($qaleb['singl-bread-ac']=='1'){?><div class="crumbs"><a href="<?php bloginfo('url'); ?>">خانه</a>  <?php the_category(' ' ); ?> </div> <?php } ?>
<?php if($qaleb['rotitr']=='1'){?><?php if(get_post_meta( get_the_ID(), 'meta-text-1', true )!=null){ ?><div class="rotitr"><?php echo get_post_meta( get_the_ID(), 'meta-text-1', true ); ?></div> <?php } ?><?php } ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<ul class="news-detile">
<?php if($qaleb['singl-category-ac']=='1'){?><li><i class="fa fa-file-text-o"></i><span>کد خبر : <?php the_ID();?></span></li><?php } ?>
<?php if($qaleb['singl-date-ac']=='1'){?><li><i class="fa fa-calendar"></i><span><?php the_time(' d F Y  -  G:i');  ?></span></li><?php } ?>
<li class="news-save">
<?php if($qaleb['print']=='1'){?><a class="print" href="#" onclick='window.open("<?php the_permalink();?>?print=1", "printwin","left=200,top=200,width=820,height=550,toolbar=1,resizable=0,status=0,scrollbars=1");'></a><?php } ?>
<?php if($qaleb['send']=='1'){?><?php echo direct_email('') ?><?php } ?>
</li>
<?php if($qaleb['single-font-ac']=='1'){?>
<li class="news-save">
<div class="fontsize">
<div class="plustext"><i class="fa fa-plus"></i></div>
<a class="size_reset"><i class="fa fa-pencil"></i></a> 
<div class="minustext"><i class="fa fa-minus"></i></div>
</div>
</li>
<?php } ?>
</ul>

<?php if($qaleb['tarhh'] == '1'){?>
<?php if($qaleb['imag']=='1'){?>
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('slider'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
</div>
<?php } ?>
<?php if($qaleb['lide']=='1'){?><div class="lead"><?php if(get_meta('lead') != false) : echo get_meta('lead'); else : the_excerpt(); endif; ?></div><?php } ?>
<?php }else{ ?>
<div class="tarhh">
<?php if($qaleb['imag']=='1'){?>
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('slider'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
</div>
<?php } ?>
<?php if($qaleb['lide']=='1'){?><div class="lead"><?php if(get_meta('lead') != false) : echo get_meta('lead'); else : the_excerpt(); endif; ?></div><?php } ?>
</div>
<?php } ?>
</header>
<div class="entry">
<?php if ( have_posts() ) { while ( have_posts() ) {the_post(); ?>
<?php setPostViews(get_the_ID());?>
<?php
add_filter('post_gallery', 'my_post_gallery', 10, 2);
function my_post_gallery($output, $attr) {
global $post;

if (isset($attr['orderby'])) {
$attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
if (!$attr['orderby'])
unset($attr['orderby']);
}

extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr));

$id = intval($id);
if ('RAND' == $order) $orderby = 'none';

if (!empty($include)) {
$include = preg_replace('/[^0-9,]+/', '', $include);
$_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));

$attachments = array();
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
}

if (empty($attachments)) return '';

$output = "<div class=\"lightgallery gallery\">\n";

foreach ($attachments as $id => $attachment) {

$img = wp_get_attachment_image_src($id, 'full');

$output .= "<a href=\"{$img[0]}\" class=\"col-lg-4 col-md-6 col-sm-12\">\n";
$output .= "<img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" />\n";
$output .= "</a>\n";
}

$output .= "</div>\n";

return $output;
}
the_content(); ?>
<?php } } ?>
</div>
<div class="post-link">
<?php if($qaleb['singl-link-ac']=='1'){?><div class="short"><span><i class="fa fa-link"></i> لینک کوتاه : </span><b><?php echo wp_get_shortlink(); ?></b></div><?php } ?>
<?php if($qaleb['single-social-ac']=='1'){?>
<ul class="social">
<li><a class="facebook tooltip tooltip-top" data-iro="اشتراک گذاری در فیسبوک" target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" > <i class="fa fa-facebook"></i></a></li>
<li><a class="twitter tooltip tooltip-top" data-iro="اشتراک گذاری در تویتر" target="_blank" href="http://twitter.com/home?status=<?php the_permalink(); ?>"> <i class="fa fa-twitter"></i></a></li>
<li><a class="google-plus tooltip tooltip-top" data-iro="اشتراک گذاری در گوگل پلاس" target="_blank" href="http://plus.google.com/share?url=<?php the_permalink(); ?>"> <i class="fa fa-google-plus"></i></a></li>
<li><a class="linkedin tooltip tooltip-top" data-iro="اشتراک گذاری در لینکداین" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&amp;url=<?php the_permalink() ?>"> <i class="fa fa-linkedin"></i></a></li>
<li><a class="telegram tooltip tooltip-top" data-iro="اشتراک گذاری در تلگرام" target="_blank" href="https://telegram.me/share/url?url=<?php the_permalink(); ?>"> <i class="fa fa-paper-plane"></i></a></li>
<li><a class="whatsapp tooltip tooltip-top" data-iro="اشتراک گذاری در واتساپ"target="_blank" href="https://wa.me/?text=<?php the_permalink(); ?>"> <i class="fa fa-whatsapp"></i></a></li>
</ul> 
<?php } ?>
</div>
<div class="post-mata">
<ul>
<?php if(get_post_meta( get_the_ID(), 'meta-text-3', true )!=null){ ?><li><i class="fa fa-pencil" aria-hidden="true"></i> نویسنده : <?php echo get_post_meta( get_the_ID(), 'meta-text-3', true ); ?> </li><?php } ?>
<?php if($qaleb['singl-user-ac']=='1'){?><li><i class="fa fa-user" aria-hidden="true"></i> ارسال توسط : <?php the_author_posts_link(); ?></li><?php } ?>
<?php if(get_post_meta( get_the_ID(), 'meta-text-4', true )!=null){ ?><li><i class="fa fa-question-circle-o" aria-hidden="true"></i> منبع : <?php echo get_post_meta( get_the_ID(), 'meta-text-4', true ); ?></li><?php } ?>
<?php if($qaleb['singl-view-ac']=='1'){?><li><i class="fa fa-eye" aria-hidden="true"></i> <?php echo getPostViews (get_the_ID()); ?></li><?php } ?>
<?php if($qaleb['singl-comments-ac']=='1'){?><li><i class="fa fa-commenting-o" aria-hidden="true"></i>  <?php comments_popup_link('بدون دیدگاه', 'يک دیدگاه', '% دیدگاه'); ?></li><?php } ?>
</ul>
</div>
</div>

<?php if($qaleb['ads-post-bottom']=='1'){?><div class="jmb_banner"><?php echo $qaleb['ads-post-bottom-html'];?></div><?php } ?>


<?php if($qaleb['singl-tags-ac']=='1'){?><?php get_template_part('inc/tage'); ?><?php } ?>
<?php if($qaleb['relate-default']=='1'){?>
<?php if($qaleb['norm-or-tage'] == '1'){?>
<?php get_template_part('inc/relat-norm'); ?>
<?php }else{ ?>
<?php get_template_part('inc/relat-tage'); ?>
<?php } ?>
<?php } ?>
<div class="boxx">
<div class="tit">
<h4><span><?php echo $qaleb['single-comment-title']; ?></span></h4>
<?php if($qaleb['comments-1'] == '1'){?><strong><?php $comments_count = wp_count_comments(get_the_ID()); echo "مجموع دیدگاهها : " . $comments_count->total_comments; ?></strong><?php } ?>
<?php if($qaleb['comments-2'] == '1'){?><strong><?php $comments_count = wp_count_comments(get_the_ID()); echo "در انتظار بررسی : " . $comments_count->moderated; ?></strong><?php } ?>
<?php if($qaleb['comments-3'] == '1'){?><strong>انتشار یافته : <?php comments_number('0', '1', '%' );?></strong><?php } ?>
</div>
<div class="aa">
<div class="single_comments">
<?php comments_template(); ?>
</div></div>
</div>
</div>
<div class="co-aside sidebar"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('post') ) : ?><?php endif; ?></div>
<div class="co-ads sidebar"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('ads') ) : ?><?php endif; ?></div>
<div class="clearfix"></div>
</div>
</section>
<style>.content .gallery a{width:31%;}.content .gallery img {height: auto !important;}</style>
<?php get_footer(); ?>
<script type="text/javascript">
$(document).ready(function() {
$(".lightgallery").lightGallery();
});
</script>