Sindbad~EG File Manager

Current Path : /var/www/html/forumdainovacaors.com.br/wp-content/themes/itt/lists/
Upload File :
Current File : /var/www/html/forumdainovacaors.com.br/wp-content/themes/itt/lists/list-encontros.php

<?php
$showAll = $_GET['showAll'];
$yearFilter = $_GET['yearFilter'];
$posts_per_page = 5;

$user_id = get_current_user_id();
$user_data = get_userdata($user_id);
$registration_date = $user_data->user_registered;

$year_registration_user = date('Y', strtotime($registration_date));

$query_args = array(
	'post_type' => 'encontros',
	'post_status' => 'publish',
	'orderby' => 'date',
	'order'   => 'DESC',
	'posts_per_page' => $showAll ? -1 : $posts_per_page,
);

if (!is_user_admin()) {

	$dateQuery = [
		'year' => $year_registration_user,
		'compare' => '>='
	];
	$query_args["date_query"] = $dateQuery;
}

if ($yearFilter) {
	$dateQuery =  [
		'year' => date('Y', strtotime(get_years()[$yearFilter]))
	];
	$query_args["date_query"] = $dateQuery;
}

if (get_query_var('term')) {
	$query_args['tax_query'] = array(
		array(
			'taxonomy' => 'category_encontros',
			'field'    => 'slug',
			'terms'    => get_query_var('term'),
		),
	);
}

$the_query = new WP_Query($query_args);
$encontros = array();

while ($the_query->have_posts()) {
	$the_query->the_post();
	$encontros[] = array(
		'id' => $post->ID,
		'title' => get_the_title(),
		'description' => get_field('description'),
		'count_attachments' => substr_count(get_field('attachments'), ' href'),
		'date' => get_the_date('Y-m-d'),
		'link' => get_post_permalink(),
		'img' => get_the_post_thumbnail_url(),
	);
}
?>
<?php
set_query_var('title', __('ENCONTROS', 'itt'));
?>
<section class="list">
	<div class="container mt-4">
		<div class="row d-flex flex-wrap">
			<div class="col-sm-8 m-0 p-0 order-md-1 order-2 list-wrapper">
				<?php if (count($encontros) > 0) : ?>
					<?php foreach ($encontros as $key => $row) : ?>
						<div class="col-sm-12 mb-4">
							<?php
							set_query_var('encontro', $row);
							get_template_part('components/item', 'card-encontro');
							?>
						</div>
					<?php endforeach; ?>
					<?php if (!$showAll && count($encontros) >= $posts_per_page) : ?>
						<div class="col-sm-12 mb-4">
							<?php if (get_query_var('term')) : ?>
								<a class="btn-show-more w-100" href="?category_encontros=<?php echo get_query_var('term') ?>&showAll=true#showmore">
									<img src="<?php echo get_template_directory_uri(); ?>/public/assets/images/plus-sign-to-add.svg" />
								</a>
							<?php elseif ($_GET['yearFilter']) : ?>
								<a class="btn-show-more w-100" href="?yearFilter=<?php echo $_GET['yearFilter'] ?>&showAll=true#showmore">
									<img src="<?php echo get_template_directory_uri(); ?>/public/assets/images/plus-sign-to-add.svg" />
								</a>
							<?php else : ?>
								<a class=" btn-show-more w-100" href="?showAll=true#showmore">
									<img src="<?php echo get_template_directory_uri(); ?>/public/assets/images/plus-sign-to-add.svg" />
								</a>
							<?php endif ?>
						</div>
					<?php endif ?>
				<?php else : ?>
					<div class="col-sm-12 mb-2">
						<div class="card card-horizontal not-click">
							<div class="card-body">
								<div class="row">
									<div class="col-md-10">
										<div class="row">
											<div class="col-md-12 d-flex">
											</div>
											<div class="col-md-10">
												<?php echo _e('Nenhum resultado encontrado', 'itt'); ?>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				<?php endif ?>
			</div>
			<div class="col-sm-4 order-md-2 order-1 text-center">
				<div class="categories my-4 not-click card-sticky">
					<div class="title">
						<h5 class="bold">
							<?php echo  _e('CATEGORIAS', 'itt'); ?>
						</h5>
					</div>
					<div class="card-body">
						<?php
						$taxonomy = 'category_encontros';
						// busca todas as taxonomias e armazena em um array
						$taxonomies = get_taxonomies('', 'names');

						// se existir a taxonomia ele apresenta os termos para filtrar
						// monta query: '?' . [category_name] = [term]
						if (in_array($taxonomy, $taxonomies)) {
							$terms = get_terms($taxonomy);
							foreach ($terms as $linha) {
								$taxonomy_url = '?' . $taxonomy . '=';
								$terms_url = $taxonomy_url . $linha->slug;
								if (get_query_var('term') == $linha->slug) {
									$class = 'active';
								} else {
									$class = 'primary';
								}
								echo '<a href="' . $terms_url . '" >' .
									'<span class="badge badge-' . $class . '">' .
									strtoupper($linha->name) .
									'</span>' .
									'</a><br>';
							}
						}
						?>
					</div>
					<div class="title">
						<h5 class="bold">
							<?php echo  _e('ANOS', 'itt'); ?>
						</h5>
					</div>
					<div class="year-list">
						<?php
						$yearPrint = array_keys(get_years());
						foreach ($yearPrint as $year) {

							if ($year < $year_registration_user && !is_user_admin()) {
								continue;
							}

							if ($_GET['yearFilter'] == $year) {
								$class = 'active';
							} else {
								$class = 'primary';
							}
							echo '
						<a href="?yearFilter=' . $year . '">' .
								'<span class="badge badge-' . $class . '">' . $year . '</span>
						</a>
						<br>';
						}
						?>
					</div>

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

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists