2020-03-19 08:34:31 -04:00
|
|
|
<?php
|
2020-05-24 04:17:41 -04:00
|
|
|
if (!defined('ABSPATH')) {
|
|
|
|
die;
|
|
|
|
} // Cannot access pages directly.
|
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
/**
|
|
|
|
* This is the Main Query Function For Query the Event List, Just Pass the Required values It will return the Query As Object.
|
|
|
|
*/
|
|
|
|
function mep_event_query($show, $sort = '', $cat = '', $org = '', $city = '', $country = '', $evnt_type = 'upcoming')
|
|
|
|
{
|
|
|
|
$event_expire_on_old = mep_get_option('mep_event_expire_on_datetimes', 'general_setting_sec', 'event_start_datetime');
|
2020-04-08 14:30:01 -04:00
|
|
|
$event_expire_on = $event_expire_on_old == 'event_end_datetime' ? 'event_expire_datetime' : $event_expire_on_old;
|
2020-03-19 08:34:31 -04:00
|
|
|
$now = current_time('Y-m-d H:i:s');
|
2020-12-17 05:11:50 -05:00
|
|
|
if ( get_query_var('paged') ) {
|
2021-02-25 06:55:25 -05:00
|
|
|
$paged = get_query_var('paged');
|
|
|
|
} elseif ( get_query_var('page') ) {
|
|
|
|
$paged = get_query_var('page');
|
|
|
|
} else {
|
|
|
|
$paged = 1;
|
2020-12-17 05:11:50 -05:00
|
|
|
}
|
2020-03-19 08:34:31 -04:00
|
|
|
$etype = $evnt_type == 'expired' ? '<' : '>';
|
2020-04-08 14:30:01 -04:00
|
|
|
|
2021-02-25 06:55:25 -05:00
|
|
|
|
|
|
|
$cat_id = explode(',',$cat);
|
|
|
|
$org_id = explode(',',$org);
|
|
|
|
|
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$cat_filter = !empty($cat) ? array(
|
|
|
|
'taxonomy' => 'mep_cat',
|
|
|
|
'field' => 'term_id',
|
2021-02-25 06:55:25 -05:00
|
|
|
'terms' => $cat_id
|
2020-04-28 06:37:33 -04:00
|
|
|
) : '';
|
2020-04-08 14:30:01 -04:00
|
|
|
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$org_filter = !empty($org) ? array(
|
|
|
|
'taxonomy' => 'mep_org',
|
|
|
|
'field' => 'term_id',
|
2021-02-25 06:55:25 -05:00
|
|
|
'terms' => $org_id
|
2020-04-28 06:37:33 -04:00
|
|
|
) : '';
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$city_filter = !empty($city) ? array(
|
|
|
|
'key' => 'mep_city',
|
|
|
|
'value' => $city,
|
|
|
|
'compare' => 'LIKE'
|
|
|
|
) : '';
|
|
|
|
$country_filter = !empty($country) ? array(
|
|
|
|
'key' => 'mep_country',
|
|
|
|
'value' => $country,
|
|
|
|
'compare' => 'LIKE'
|
|
|
|
) : '';
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$expire_filter = !empty($event_expire_on) ? array(
|
|
|
|
'key' => $event_expire_on,
|
|
|
|
'value' => $now,
|
|
|
|
'compare' => $etype
|
|
|
|
) : '';
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$args = array(
|
|
|
|
'post_type' => array('mep_events'),
|
|
|
|
'paged' => $paged,
|
|
|
|
'posts_per_page' => $show,
|
|
|
|
'order' => $sort,
|
|
|
|
'orderby' => 'meta_value',
|
2021-09-03 06:25:05 -04:00
|
|
|
// 'meta_key' => 'event_start_datetime',
|
|
|
|
'meta_key' => 'event_upcoming_datetime',
|
2020-04-28 06:37:33 -04:00
|
|
|
'meta_query' => array(
|
|
|
|
$expire_filter,
|
|
|
|
$city_filter,
|
|
|
|
$country_filter
|
|
|
|
),
|
|
|
|
'tax_query' => array(
|
|
|
|
$cat_filter,
|
|
|
|
$org_filter
|
|
|
|
)
|
|
|
|
);
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
$loop = new WP_Query($args);
|
2020-03-19 08:34:31 -04:00
|
|
|
|
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
return $loop;
|
|
|
|
}
|
2020-03-19 08:34:31 -04:00
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
/**
|
|
|
|
* This is the Main Function For Pagination the Event List, Just Pass the Required values It will return the Pagination with HTML
|
|
|
|
*/
|
|
|
|
function mep_event_pagination($total_page)
|
|
|
|
{
|
2020-12-17 05:11:50 -05:00
|
|
|
|
|
|
|
if ( get_query_var('paged') ) {
|
|
|
|
|
|
|
|
$paged = get_query_var('paged');
|
|
|
|
|
|
|
|
} elseif ( get_query_var('page') ) {
|
|
|
|
|
|
|
|
$paged = get_query_var('page');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$paged = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-28 06:37:33 -04:00
|
|
|
?>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<?php
|
|
|
|
$pargs = array(
|
|
|
|
"current" => $paged,
|
|
|
|
"total" => $total_page
|
|
|
|
);
|
|
|
|
echo "<div class='pagination-sec'>" . paginate_links($pargs) . "</div>";
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
2020-12-17 05:11:50 -05:00
|
|
|
|
|
|
|
|