<div class="page-margin">
	<div class="row">
		<div class="col-md-2 leftcol"><?php echo Wo_LoadPage("sidebar/left-sidebar"); ?></div>
		<div class="col-md-7 profile-lists singlecol">
			<div class="page-margin mt-0">
				<div class="wow_content popular_posts_hdr movie">
					<img src="<?php echo $wo['config']['theme_url'];?>/img/blog.png" class="bg_trail">
					<h2><svg width="17" height="18" viewBox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.61171 6.79433C2.12446 4.55719 3.83126 2.8104 6.0172 2.28564C7.59585 1.90666 9.23879 1.90666 10.8174 2.28564C13.0034 2.8104 14.7102 4.55719 15.2229 6.79434C15.5932 8.40998 15.5932 10.0914 15.2229 11.707C14.7102 13.9442 13.0034 15.691 10.8174 16.2157C9.23878 16.5947 7.59585 16.5947 6.0172 16.2157C3.83126 15.691 2.12446 13.9442 1.61171 11.707C1.24141 10.0914 1.24141 8.40998 1.61171 6.79433Z" class="icon_main" stroke-width="1.5" stroke-linecap="round"></path><path d="M5.14258 1.5V3.59479M11.6924 1.5V3.59479M5.96131 11.7645H8.41751M5.96131 9.25071H10.8737" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>&nbsp;<?php echo $wo['lang']['most_recent_art']; ?></h2>
				</div>
			</div>
			
			<div class="page-margin wow_content wow_big_head_link flex">
				<ul class="list-unstyled">
					<?php if ($wo['loggedin'] == true) { ?>
					<?php if (Wo_CanBlog() == true) { ?>
					<li><a href="<?php echo Wo_SeoLink('index.php?link1=my-blogs'); ?>" data-ajax="?link1=my-blogs"><?php echo $wo['lang']['my_articles'] ?></a></li>
					<?php } } ?>
					<li class="active"><a href="<?php echo Wo_SeoLink('index.php?link1=blogs'); ?>" data-ajax="?link1=blogs"><?php echo $wo['lang']['browse_articles'] ?></a></li>
				</ul>
				<div class="right_part">
					<div class="search-blog">
						<form action="">
							<input type="text" placeholder="<?php echo $wo['lang']['search_for_article']?>" id="search-blog-input">
							<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="9" cy="9" r="8" stroke="currentColor" stroke-width="2"></circle><path d="M14.5 15.5L18.5 19.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>
						</form>
					</div>
				</div>
			</div>
			
			<div class="page-margin wow_content wow_big_head_link">
				<ul class="list-unstyled">
					<?php 
						$category_id = (!empty($_GET['id'])) ? (int) $_GET['id'] : 0;
						foreach ($wo['blog_categories'] as $key => $category) {
							$active = ($category_id == $key) ? 'active' : '';
					?>
						<li class="<?php echo $active?>"><a href="<?php echo Wo_SeoLink('index.php?link1=blog-category&id=' . $key) ?>" data-ajax="?link1=blog-category&id=<?php echo $key?>"><?php echo $category;?></a></li>
					<?php } ?>
				</ul>
			</div>
			
			<div id="blog-list" class="latest-blogs row">
				<?php
					$pages = Wo_GetBlogs(array("category" => $_GET['id'],'limit' => 10));
					if (count($pages) > 0) {
						foreach ($pages as $wo['blog']) {
							echo Wo_LoadPage('blog/includes/card-horiz-list');
						}
					} 
					else {
						echo '<div class="col-md-12"><div class="wow_content"><div class="empty_state"><svg width="17" height="18" viewBox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.61171 6.79433C2.12446 4.55719 3.83126 2.8104 6.0172 2.28564C7.59585 1.90666 9.23879 1.90666 10.8174 2.28564C13.0034 2.8104 14.7102 4.55719 15.2229 6.79434C15.5932 8.40998 15.5932 10.0914 15.2229 11.707C14.7102 13.9442 13.0034 15.691 10.8174 16.2157C9.23878 16.5947 7.59585 16.5947 6.0172 16.2157C3.83126 15.691 2.12446 13.9442 1.61171 11.707C1.24141 10.0914 1.24141 8.40998 1.61171 6.79433Z" class="icon_main" stroke-width="1.5" stroke-linecap="round"></path><path d="M5.14258 1.5V3.59479M11.6924 1.5V3.59479M5.96131 11.7645H8.41751M5.96131 9.25071H10.8737" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>' . $wo['lang']['no_blogs_found'] . '</div></div></div>';
					}
				?>
			</div>
			
			<div class="posts_load">
				<?php if (count($pages) >= 0): ?>
					<div class="load-more">
						<button class="btn btn-default text-center pointer load-more-blogs" id="hren"><?php echo $wo['lang']['load_more_blogs'] ?></button>
					</div>
				<?php endif ?>
			</div>
		</div>
	</div>
</div>

<script>
jQuery(document).ready(function($) {
  var delay = (function(){
    var timer = 0;
    return function(callback, ms){
      clearTimeout (timer);
      timer = setTimeout(callback, ms);
    };
  })();

  $("#search-art").keyup(function() {
      delay(function(){
      if ($("#search-art").val().trim()) {
	      $.ajax({
	        url: Wo_Ajax_Requests_File(),
	        type: 'GET',
	        data: {f:"search-art",keyword:$("#search-art").val(),cat:'<?php echo $_GET['id']; ?>'},
	        dataType: "json",
	        success: function(data){
	          if (data['status'] == 200) {
	          	$(".latest-blogs").html(data['html'])
	          }else{
	          	$("#blog-list").html('<div class="empty_state"> ' + data['warning'] + '</div>')
	          }
	        }
	      })}
      }, 1000 );
  });

   $(".load-more-blogs").click(function () {
      $.ajax({
         url: Wo_Ajax_Requests_File(),
         type: 'GET',
         dataType: 'json',
         data: {f:"load-blogs",offset:($(".wow_main_blogs").length > 0) ? $(".wow_main_blogs:last").attr('id') : 0,id:<?php echo $_GET['id'] ?>},
         success:function(data){
            if (data['status'] == 200) {
            	$(".latest-blogs h5.search-filter-center-text").remove();
                $(".latest-blogs").append(data['html'])
             }else{
               $(".posts_load").remove()
             }
         }
      })
   });
});
</script>