mage-eventpress/inc/template-prts/event_location.php

371 lines
16 KiB
PHP
Raw Normal View History

2021-08-08 01:03:30 -04:00
<?php
2020-05-24 04:17:41 -04:00
if (!defined('ABSPATH')) {
die;
} // Cannot access pages directly.
2021-08-08 01:03:30 -04:00
add_action('mep_event_location', 'mep_ev_location_ticket');
add_action('mep_event_location_ticket', 'mep_ev_location_ticket', 10, 2);
2020-01-22 07:15:24 -05:00
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_location_cart')) {
2021-08-08 01:03:30 -04:00
function mep_ev_location_cart($event_id, $event_meta)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true) ? get_post_meta($event_id, 'mep_org_address', true) : '';
ob_start();
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
$location = get_term_meta($org_id, 'org_location', true) ? get_term_meta($org_id, 'org_location', true) : '';
$street = get_term_meta($org_id, 'org_street', true) ? get_term_meta($org_id, 'org_street', true) : '';
$city = get_term_meta($org_id, 'org_city', true) ? get_term_meta($org_id, 'org_city', true) : '';
$state = get_term_meta($org_id, 'org_state', true) ? get_term_meta($org_id, 'org_state', true) : '';
$zip = get_term_meta($org_id, 'org_postcode', true) ? get_term_meta($org_id, 'org_postcode', true) : '';
$country = get_term_meta($org_id, 'org_country', true) ? get_term_meta($org_id, 'org_country', true) : '';
} else {
$location = get_post_meta($event_id, 'mep_location_venue', true) ? get_post_meta($event_id, 'mep_location_venue', true) : '';
$street = get_post_meta($event_id, 'mep_street', true) ? get_post_meta($event_id, 'mep_street', true) : '';
$city = get_post_meta($event_id, 'mep_city', true) ? get_post_meta($event_id, 'mep_city', true) : '';
$state = get_post_meta($event_id, 'mep_state', true) ? get_post_meta($event_id, 'mep_state', true) : '';
$zip = get_post_meta($event_id, 'mep_postcode', true) ? get_post_meta($event_id, 'mep_postcode', true) : '';
$country = get_post_meta($event_id, 'mep_country', true) ? get_post_meta($event_id, 'mep_country', true) : '';
}
$location_arr = [$location, $street, $city, $state, $zip, $country];
2022-01-24 00:06:54 -05:00
echo esc_html(implode(', ', array_filter($location_arr)));
2021-08-08 01:03:30 -04:00
$content = ob_get_clean();
$address_arr = array(
'location' => $location,
'street' => $street,
'state' => $state,
'zip' => $zip,
'city' => $city,
'country' => $country
);
echo apply_filters('mage_event_location_in_cart', $content, $event_id, $event_meta, $address_arr);
}
2023-11-06 01:31:17 -05:00
}
2020-01-22 07:15:24 -05:00
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_location_ticket')) {
2021-08-08 01:03:30 -04:00
function mep_ev_location_ticket($event_id, $event_meta='')
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true) ? get_post_meta($event_id, 'mep_org_address', true) : '';
ob_start();
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
$location = get_term_meta($org_id, 'org_location', true) ? get_term_meta($org_id, 'org_location', true) : '';
$street = get_term_meta($org_id, 'org_street', true) ? get_term_meta($org_id, 'org_street', true) : '';
$city = get_term_meta($org_id, 'org_city', true) ? get_term_meta($org_id, 'org_city', true) : '';
$state = get_term_meta($org_id, 'org_state', true) ? get_term_meta($org_id, 'org_state', true) : '';
$zip = get_term_meta($org_id, 'org_postcode', true) ? get_term_meta($org_id, 'org_postcode', true) : '';
$country = get_term_meta($org_id, 'org_country', true) ? get_term_meta($org_id, 'org_country', true) : '';
} else {
$location = get_post_meta($event_id, 'mep_location_venue', true) ? get_post_meta($event_id, 'mep_location_venue', true) : '';
$street = get_post_meta($event_id, 'mep_street', true) ? get_post_meta($event_id, 'mep_street', true) : '';
$city = get_post_meta($event_id, 'mep_city', true) ? get_post_meta($event_id, 'mep_city', true) : '';
$state = get_post_meta($event_id, 'mep_state', true) ? get_post_meta($event_id, 'mep_state', true) : '';
$zip = get_post_meta($event_id, 'mep_postcode', true) ? get_post_meta($event_id, 'mep_postcode', true) : '';
$country = get_post_meta($event_id, 'mep_country', true) ? get_post_meta($event_id, 'mep_country', true) : '';
}
2021-09-03 06:25:05 -04:00
$location_arr = [$location, $street, $city, $state, $zip, $country];
2022-01-24 00:06:54 -05:00
echo esc_html(implode(', ', array_filter($location_arr)));
2021-08-08 01:03:30 -04:00
$content = ob_get_clean();
$address_arr = array(
'location' => $location,
'street' => $street,
'state' => $state,
'zip' => $zip,
'city' => $city,
'country' => $country
);
echo apply_filters('mage_event_location_in_ticket', $content, $event_id, $event_meta, $address_arr);
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_location')) {
2021-08-08 01:03:30 -04:00
function mep_ev_location()
{
global $post, $event_meta;
$event_id = $post->ID;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true) ? get_post_meta($post->ID, 'mep_org_address', true) : '';
ob_start();
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
$location = get_term_meta($org_id, 'org_location', true) ? '<p>' . get_term_meta($org_id, 'org_location', true) . '</p>' : '';
$street = get_term_meta($org_id, 'org_street', true) ? '<p>' . get_term_meta($org_id, 'org_street', true) . '</p>' : '';
$city = get_term_meta($org_id, 'org_city', true) ? '<p>' . get_term_meta($org_id, 'org_city', true) . '</p>' : '';
$state = get_term_meta($org_id, 'org_state', true) ? '<p>' . get_term_meta($org_id, 'org_state', true) . '</p>' : '';
$zip = get_term_meta($org_id, 'org_postcode', true) ? '<p>' . get_term_meta($org_id, 'org_postcode', true) . '</p>' : '';
$country = get_term_meta($org_id, 'org_country', true) ? '<p>' . get_term_meta($org_id, 'org_country', true) . '</p>' : '';
} else {
$location = get_post_meta($event_id, 'mep_location_venue', true) ? '<p>' . get_post_meta($event_id, 'mep_location_venue', true) . '</p>' : '';
$street = get_post_meta($event_id, 'mep_street', true) ? '<p>' . get_post_meta($event_id, 'mep_street', true) . '</p>' : '';
$city = get_post_meta($event_id, 'mep_city', true) ? '<p>' . get_post_meta($event_id, 'mep_city', true) . '</p>' : '';
$state = get_post_meta($event_id, 'mep_state', true) ? '<p>' . get_post_meta($event_id, 'mep_state', true) . '</p>' : '';
$zip = get_post_meta($event_id, 'mep_postcode', true) ? '<p>' . get_post_meta($event_id, 'mep_postcode', true) . '</p>' : '';
$country = get_post_meta($event_id, 'mep_country', true) ? '<p>' . get_post_meta($event_id, 'mep_country', true) . '</p>' : '';
}
$location_arr = [$location, $street, $city, $state, $zip, $country];
2022-01-24 00:06:54 -05:00
echo esc_html(implode(', ', array_filter($location_arr)));
2021-08-08 01:03:30 -04:00
$content = ob_get_clean();
$address_arr = array(
'location' => $location,
'street' => $street,
'state' => $state,
'zip' => $zip,
'city' => $city,
'country' => $country
);
echo apply_filters('mage_event_location_content', $content, $post->ID, $event_meta, $address_arr);
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_venue', 'mep_ev_venue');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_venue')) {
2023-07-24 22:16:45 -04:00
function mep_ev_venue($event_id)
2021-08-08 01:03:30 -04:00
{
global $post, $event_meta;
2023-07-24 22:16:45 -04:00
2021-08-08 01:03:30 -04:00
if ($event_id) {
$event = $event_id;
} else {
$event = $post->ID;
}
2023-07-24 22:16:45 -04:00
2021-08-08 01:03:30 -04:00
$location_sts = get_post_meta($event, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event, 'mep_org');
$org_id = $org_arr[0]->term_id;
echo get_term_meta($org_id, 'org_location', true);
} else {
echo get_post_meta($event, 'mep_location_venue', true);
}
}
2020-05-24 04:17:41 -04:00
}
2023-07-24 22:16:45 -04:00
2023-11-06 01:31:17 -05:00
2020-03-24 04:09:00 -04:00
/**
* Event Location Get Functions
*/
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_get_event_location')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_location', true);
} else {
return get_post_meta($event_id, 'mep_location_venue', true);
}
2020-03-24 04:09:00 -04:00
}
}
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_get_event_location_street')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location_street($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_street', true);
} else {
return get_post_meta($event_id, 'mep_street', true);
}
2020-03-24 04:09:00 -04:00
}
}
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_get_event_location_city')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location_city($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_city', true);
} else {
return get_post_meta($event_id, 'mep_city', true);
}
2020-03-24 04:09:00 -04:00
}
}
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_get_event_location_state')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location_state($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_state', true);
} else {
return get_post_meta($event_id, 'mep_state', true);
}
2020-03-24 04:09:00 -04:00
}
}
2021-08-08 01:03:30 -04:00
function mep_get_location_name_for_list($event_id)
{
2020-05-24 04:17:41 -04:00
}
if (!function_exists('mep_get_event_location_postcode')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location_postcode($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_postcode', true);
} else {
return get_post_meta($event_id, 'mep_postcode', true);
}
2020-03-24 04:09:00 -04:00
}
}
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_get_event_location_country')) {
2021-08-08 01:03:30 -04:00
function mep_get_event_location_country($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($event_id, 'mep_org');
$org_id = $org_arr[0]->term_id;
return get_term_meta($org_id, 'org_country', true);
} else {
return get_post_meta($event_id, 'mep_country', true);
}
2020-03-24 04:09:00 -04:00
}
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_street', 'mep_ev_street');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_street')) {
2021-08-08 01:03:30 -04:00
function mep_ev_street()
{
global $post, $event_meta;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($post->ID, 'mep_org');
$org_id = $org_arr[0]->term_id;
2021-10-31 07:01:04 -04:00
?>
<span><?php echo get_term_meta($org_id, 'org_street', true); ?></span>
<?php } else { ?>
<span><?php echo esc_html($event_meta['mep_street'][0]); ?></span>
2021-08-08 01:03:30 -04:00
<?php
}
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_city', 'mep_ev_city');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_city')) {
2021-08-08 01:03:30 -04:00
function mep_ev_city()
{
global $post, $event_meta;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($post->ID, 'mep_org');
$org_id = $org_arr[0]->term_id;
2021-10-31 07:01:04 -04:00
?>
<span><?php echo get_term_meta($org_id, 'org_city', true); ?></span>
<?php } else { ?>
<span><?php echo esc_html($event_meta['mep_city'][0]); ?></span>
2021-08-08 01:03:30 -04:00
<?php
}
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_state', 'mep_ev_state');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_state')) {
2021-08-08 01:03:30 -04:00
function mep_ev_state()
{
global $post, $event_meta;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($post->ID, 'mep_org');
$org_id = $org_arr[0]->term_id;
2021-10-31 07:01:04 -04:00
?>
<span><?php echo get_term_meta($org_id, 'org_state', true); ?></span>
<?php } else { ?>
<span><?php echo esc_html($event_meta['mep_state'][0]); ?></span>
2021-08-08 01:03:30 -04:00
<?php
}
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_postcode', 'mep_ev_postcode');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_postcode')) {
2021-08-08 01:03:30 -04:00
function mep_ev_postcode()
{
global $post, $event_meta;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($post->ID, 'mep_org');
$org_id = $org_arr[0]->term_id;
2021-10-31 07:01:04 -04:00
?>
<span><?php echo get_term_meta($org_id, 'org_postcode', true); ?></span>
<?php } else { ?>
<span><?php echo esc_html($event_meta['mep_postcode'][0]); ?></span>
2021-08-08 01:03:30 -04:00
<?php
}
}
2020-05-24 04:17:41 -04:00
}
2020-01-22 07:15:24 -05:00
2021-08-08 01:03:30 -04:00
add_action('mep_event_location_country', 'mep_ev_country');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_ev_country')) {
2021-08-08 01:03:30 -04:00
function mep_ev_country()
{
global $post, $event_meta;
$location_sts = get_post_meta($post->ID, 'mep_org_address', true);
if ($location_sts) {
$org_arr = get_the_terms($post->ID, 'mep_org');
$org_id = $org_arr[0]->term_id;
2021-10-31 07:01:04 -04:00
?>
<span><?php echo get_term_meta($org_id, 'org_country', true); ?></span>
<?php } else { ?>
<span><?php echo esc_html($event_meta['mep_country'][0]); ?></span>
2021-08-08 01:03:30 -04:00
<?php
}
}
2020-05-24 04:17:41 -04:00
}
2021-08-08 01:03:30 -04:00
add_action('mep_event_address_list_sidebar', 'mep_event_address_list_sidebar_html');
2020-05-24 04:17:41 -04:00
if (!function_exists('mep_event_address_list_sidebar_html')) {
2021-08-08 01:03:30 -04:00
function mep_event_address_list_sidebar_html($event_id)
{
$location_sts = get_post_meta($event_id, 'mep_org_address', true);
$org_arr = get_the_terms($event_id, 'mep_org') ? get_the_terms($event_id, 'mep_org') : '';
$org_id = !empty($org_arr) ? $org_arr[0]->term_id : '';
$venue = !empty($location_sts) ? get_term_meta($org_id, 'org_location', true) : get_post_meta($event_id, 'mep_location_venue', true);
$street = !empty($location_sts) ? get_term_meta($org_id, 'org_street', true) : get_post_meta($event_id, 'mep_street', true);
$city = !empty($location_sts) ? get_term_meta($org_id, 'org_city', true) : get_post_meta($event_id, 'mep_city', true);
$state = !empty($location_sts) ? get_term_meta($org_id, 'org_state', true) : get_post_meta($event_id, 'mep_state', true);
2023-11-06 01:31:17 -05:00
$zip = !empty($location_sts) ? get_term_meta($org_id, 'org_postcode', true) : get_post_meta($event_id, 'mep_postcode', true);
2021-08-08 01:03:30 -04:00
$country = !empty($location_sts) ? get_term_meta($org_id, 'org_country', true) : get_post_meta($event_id, 'mep_country', true);
2023-11-06 01:31:17 -05:00
2021-08-08 01:03:30 -04:00
ob_start();
require(mep_template_file_path('single/location_list.php'));
echo ob_get_clean();
}
2020-05-24 04:17:41 -04:00
}