<?php get_header(); ?>
<?php global $qaleb;?>
<section class="ap_main">
<div class="container inn">
<div class="gallery-content">
<header class="heding">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="navbarh">
<?php if($qaleb['gallery-cod-ac']=='1'){?><a><i class="fa fa-file-text-o"></i> کد خبر : <?php the_ID();?></a><?php } ?>
<?php if($qaleb['gallery-date-ac']=='1'){?><a><i class="fa fa-calendar"></i> <?php the_time(' d F Y  -  G:i');  ?></a><?php } ?>		
</div>
</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['gallery-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['gallery-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-6', true )!=null){ ?><li><i class="fa fa-camera" aria-hidden="true"></i> عکس از : <?php echo get_post_meta( get_the_ID(), 'meta-text-6', true ); ?> </li><?php } ?>
<?php if($qaleb['gallery-user-ac']=='1'){?><li><i class="fa fa-user" aria-hidden="true"></i> ارسال توسط : <?php the_author_posts_link(); ?></li><?php } ?>
<?php if($qaleb['gallery-view-ac']=='1'){?><li><i class="fa fa-eye" aria-hidden="true"></i> <?php echo getPostViews (get_the_ID()); ?></li><?php } ?>
<?php if($qaleb['gallery-comments-ac']=='1'){?><li><i class="fa fa-commenting-o" aria-hidden="true"></i>  <?php comments_popup_link('بدون دیدگاه', 'يک دیدگاه', '% دیدگاه'); ?></li><?php } ?>
</ul>
</div>

</div></div></section>

<?php if($qaleb['gallery-ac']=='1'){?>
<section class="ap_main">
<div class="container inn">
<div class="boxx">
<div class="tit">
<h4><span><?php echo $qaleb['relate-gallery-title']; ?></span></h4>
</div>
<?php
$categories = get_the_category();
$cats = array();
foreach ( $categories as $category ) { 
$cats[] = esc_attr( $category->term_id ); 
}
$args = new WP_Query(array(
'post_type' =>'gallery',
'cat'	=> $cats,
'posts_per_page' => $qaleb['gallery-related-count'],
'post__not_in' => array(get_the_ID()),
));
if($args->have_posts()) : while($args->have_posts()) : $args->the_post();
?>

<div class="mediaa">	
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('loop'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
<span class="metaha medat"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php the_time('d F Y - G:i');  ?></span>
	<div class="mask-img"></div>
	<div class="meicon"><i class="fa fa-camera"></i></div>
</div>
<h2><a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>

<?php endwhile; endif;  wp_reset_query(); ?>
</div>
</div>
</section>
<?php } ?>

<section class="ap_main">
<div class="container inn">
<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>
</section>

<style>#commentform input[type="text"]{width: 48.0%;}.ap_header .inn .header_right .ap_logo img,.ap-nav{z-index: 88;}.marquee{background: #333;}.marquee-frame span a{color:#ddd !important}.main_videos{padding-top:30px;margin-top:-20px;margin-bottom:20px;}.content h1{margin-top:0;}</style>
<?php get_footer(); ?>
<script type="text/javascript">
$(document).ready(function() {
$(".lightgallery").lightGallery();
});
</script>