'Enterprise House',
'river-park-house' => 'River Park House',
'east-park-house' => 'East Park House',
'maughan-house' => 'Maughan House',
'unit-centre-1' => 'Centre Point (1 - 6)',
'unit-centre-2' => 'Centre Point (7 - 9)',
'unit-centre-3' => 'Centre Point (10 - 11)',
'unit-jdb' => 'John Dunlop Building',
'unit-portside' => 'Portside',
'unit-a' => 'Unit A',
'unit-b' => 'Unit B',
'unit-c' => 'Unit C',
'unit-e' => 'Unit E',
'unit-f' => 'Unit F',
'unit-g' => 'Unit G',
'unit-h' => 'Unit H',
'unit-i' => 'Unit I',
'unit-j' => 'Unit J',
'unit-k-1' => 'Unit K (1 - 7)',
'unit-k-2' => 'Unit K (8 - 18)',
'unit-l' => 'Unit L',
'unit-m' => 'Unit M',
'unit-n' => 'Unit N',
'unit-o' => 'Unit O',
'unit-p' => 'Unit P',
'unit-q-1' => 'Unit Q1',
'unit-q-2' => 'Unit Q2 Centre',
'unit-r' => 'Unit R',
'unit-s' => 'Unit S',
'unit-s' => 'Unit S',
);
}function sf9GetMapHTML()
{
return sprintf(
'
',
SF9_THEME_URL
);
}/**
* This gets the HTML for the map filters
*
* @return string The HTML
*/
function sf9GetMapFiltersHTML()
{// Industry
$args = array(
'hide_empty' => true,
'fields' => 'all'
);
$terms = get_terms('industry', $args);
if( empty($terms) )
{
return;
}
$html = '',
$term->slug,
$term->name
);
}$industry = sprintf(
'
%s:
',
__('Filter by Industry'),
$html
);// Area
$html = '',
$name,
$label
);
}$area = sprintf(
'%s:
',
__('Filter by Area', SF9_THEME_NAME),
$html
);// Set the final HTML
$html = sprintf(
' %s
%s
',
$industry,
$area
);return $html;}/**
* This gets the business listing HTML
*
* @param array $post The current post
* @param int $i The current increment
* @param string $class The class
* @param array $unit_areas The array of unit areas
* @return bool|string The HTML
*/
function sf9GetListingHTML($post, $i, $class, $unit_areas)
{/**
* Check for industry
*/
$args = array(
'name',
'slug'
);
$terms = wp_get_post_terms($post->ID, 'industry', $args);/**
* Return if no industry
*/
if( empty($terms) )
{
return false;
}/**
* Set the industry and filter
*/
$industry = false;
$filter = false;
foreach($terms as $term)
{
if( $industry === false )
{
$industry = $term->name;
$filter = 'filter-' . $term->slug;
}
else
{
$industry .= ', ' . $term->name;
$filter .= ' filter-' . $term->slug;
}
}/**
* Set the area and filter
*/
$area = get_post_meta($post->ID, 'unit', true);
$filter .= ' filter-' . $area;/**
* Set the params
*/
$company = apply_filters('the_title', $post->post_title);
$contact_details = '';
$contact = apply_filters('the_title', get_post_meta($post->ID, 'contact', true));
$phone = get_post_meta($post->ID, 'phone', true);
$email = get_post_meta($post->ID, 'email', true);
$website = esc_url( get_post_meta($post->ID, 'website', true) );/**
* Set the unit details
*/
$unit_details = get_post_meta($post->ID, 'unit-details', true);
if( ! $unit_details )
{
$unit_details = $unit_areas[$area];
}/**
* Set the contact details
*/
if( $contact )
{
$contact_details .= sprintf(
'',
$contact
);
}
if( $phone )
{
$contact_details .= sprintf(
'
%s ',
$phone
);
}
if( $website )
{
$contact_details .= sprintf(
'',
$website,
__('View Website', SF9_THEME_NAME)
);
}
if( is_email($email) )
{
$contact_details .= sprintf(
'',
$email,
__('Email', SF9_THEME_NAME)
);
}/**
* Set the button
*/
$buttons = sprintf(
'%1$s',
__('Show On Map', SF9_THEME_NAME)
);
$buttons .= sprintf(
'%1$s',
__('View Contact Details', SF9_THEME_NAME)
);/**
* Return the HTML
*/
return <<$company
$unit_details$area
$industry
$buttons
$contact_details
HTML;
}if( have_posts() )
{
while( have_posts() )
{
the_post();/**
* Set the params
*/
$page_title = apply_filters('the_title', $post->post_title);
$listings = '';
$filters = sf9GetMapFiltersHTML();
$map = sf9GetMapHTML();/**
* Get the business listings
*/
$args = array(
'post_type' => 'business-listing',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'unit',
),
array(
'key' => 'contact',
)
)
);$q = new WP_Query($args);if( $q->have_posts() )
{
// Set up params
$i = 1;
$class = 'odd';
$unit_areas = sf9GetUnitAreas();while( $q->have_posts() )
{
$q->the_post();// Get the listing
$listing = sf9GetListingHTML($post, $i, $class, $unit_areas);/**
* If there is a listing then add to the HTML
* and also change the class and increment the count
*/
if( $listing !== false )
{
$listings .= $listing;
$class = ( $class == 'odd' )
? 'even'
: 'odd';
$i++;}
}
wp_reset_postdata();
}/**
* Set the units for the map
*/
$unit_areas = sf9GetUnitAreas();
$units = '';
foreach($unit_areas as $name => $label)
{
$units .= sprintf(
'',
$name
);
}/**
* Output the content
*/
wp_enqueue_script('sf9-map');
$args = array();
foreach($unit_areas as $name => $label)
{
$args[] = $name;
}
wp_localize_script('sf9-map', 'units', $args);get_header();?> if (is_front_page() ) : else :?> $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full');?>

endif; ?>
HTML;
get_footer();}
}
else
{
wp_redirect(site_url());
exit;
}
?>