-
-
Save m4munib/bc54f4330a370bdd821ae4bb3c79b809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Single Listing CT IDX Pro Info | |
* | |
* @package WP Pro Real Estate 7 | |
* @subpackage Include | |
*/ | |
global $ct_options; | |
$post_id = $post->ID; | |
$ct_single_listing_content_layout_type = isset( $ct_options['ct_single_listing_content_layout_type'] ) ? $ct_options['ct_single_listing_content_layout_type'] : ''; | |
$ct_single_listing_idx_layout = isset( $ct_options['ct_single_listing_idx_layout']['enabled'] ) ? $ct_options['ct_single_listing_idx_layout']['enabled'] : ''; | |
$ct_listings_lotsize_format = isset( $ct_options['ct_listings_lotsize_format'] ) ? esc_html( $ct_options['ct_listings_lotsize_format'] ) : ''; | |
$ct_source = get_post_meta($post->ID, 'source', true); | |
$ct_idx_schools_school_district = get_post_meta($post->ID, "_ct_idx_schools_school_district", true); | |
$ct_idx_schools_elementary_school = get_post_meta($post->ID, "_ct_idx_schools_elementary_school", true); | |
$ct_idx_schools_middle_school = get_post_meta($post->ID, "_ct_idx_schools_middle_school", true); | |
$ct_idx_schools_high_school = get_post_meta($post->ID, "_ct_idx_schools_high_school", true); | |
function ct_idx_info($field) { | |
global $post; | |
$ct_field = get_post_meta($post->ID, $field, true); | |
if(is_array($ct_field)) { | |
echo implode(', ', array_map('ucwords', $ct_field)); | |
} else { | |
echo ucwords(esc_html($ct_field)); | |
} | |
} | |
do_action('before_single_listing_ct_idx_pro_info'); | |
if($ct_source == 'idx-api') { | |
echo '<!-- Listing IDX Info -->'; | |
echo '<div id="listing-idx-info">'; | |
if(!empty($ct_single_listing_idx_layout)) { | |
foreach ($ct_single_listing_idx_layout as $key => $value) { | |
switch($key) { | |
// Content | |
case 'listing_idx_overview' : | |
$grouped_features = apply_filters( 'idx_get_grouped_features', json_decode( $grouped_features, true ), $grouped_features ); | |
if( is_array( $grouped_features ) && ! empty($grouped_features) ){ | |
foreach( $grouped_features as $feature_group => $features_data ){ | |
if($ct_single_listing_content_layout_type == 'accordion') { | |
$output .= '<h4 id="idx-'. strtolower( $feature_group ) .'" class="info-toggle border-bottom marB20">'. esc_html( $feature_group ) .'</h4>'; | |
} else { | |
$output .= '<h4 id="idx-'. strtolower( $feature_group ) .'" class="border-bottom marB20">'. esc_html( $feature_group ) .'</h4>'; | |
} | |
$output .= '<div class="info-inner">'; | |
$output .= '<ul class="propinfo idx-info">'; | |
foreach( $features_data as $feature_section => $features ){ | |
$feature_parts = explode(',', $features ); | |
$feature_parts = array_map('trim', $feature_parts); | |
if( strtolower($feature_group) == 'location' && strtolower($feature_section) == 'hoa amenities' ){ | |
$hoa_lookups = [ 'monthly', 'quarterly', 'yearly', 'weekly' ]; | |
foreach( $hoa_lookups as $lookup_name ){ | |
$hoa_index = array_search($lookup_name, array_map( 'strtolower', $feature_parts ) ); | |
if( false !== $hoa_index ){ | |
$previous_index = $hoa_index - 1; | |
$formatted_str = $lookup_name; | |
if( isset($feature_parts[$previous_index]) && is_numeric($feature_parts[$previous_index]) ) { | |
$formatted_str = '$' . number_format($feature_parts[$previous_index],0) . ' ' . $formatted_str; | |
$feature_parts[$previous_index] = $formatted_str; | |
unset($feature_parts[$hoa_index]); | |
} | |
} | |
} | |
} | |
$output .= '<li class="row"><span class="muted left">'. esc_html( $feature_section ) .'</span><span class="right">'.implode(', ', $feature_parts).'</span></li>'; | |
} | |
$output .= '</ul>'; | |
$output .= '</div>'; | |
} | |
} | |
} | |
echo $output; | |
break; | |
// Schools | |
case 'listing_idx_schools' : | |
if(!empty($ct_idx_schools_school_district) || !empty($ct_idx_schools_elementary_school) || !empty($ct_idx_schools_middle_school) || !empty($ct_idx_schools_high_school)) { | |
echo '<!-- Listing IDX Schools -->'; | |
if($ct_single_listing_content_layout_type == 'accordion') { | |
echo '<h4 id="idx-schools" class="info-toggle border-bottom marB20">' . __('Schools', 'contempo') . '</h4>'; | |
} else { | |
echo '<h4 id="idx-schools" class="border-bottom marB20">' . __('Schools', 'contempo') . '</h4>'; | |
} | |
echo '<div class="info-inner">'; | |
echo '<ul class="propinfo idx-info">'; | |
if(!empty($ct_idx_schools_school_district)) { | |
echo '<li class="row district">'; | |
echo '<span class="muted left">'; | |
_e('District', 'contempo'); | |
echo '</span>'; | |
echo '<span class="right">'; | |
ct_idx_info('_ct_idx_schools_school_district'); | |
echo '</span>'; | |
echo '</li>'; | |
} | |
if(!empty($ct_idx_schools_elementary_school)) { | |
echo '<li class="row elementary-school">'; | |
echo '<span class="muted left">'; | |
_e('Elementary', 'contempo'); | |
echo '</span>'; | |
echo '<span class="right">'; | |
ct_idx_info('_ct_idx_schools_elementary_school'); | |
echo '</span>'; | |
echo '</li>'; | |
} | |
if(!empty($ct_idx_schools_middle_school)) { | |
echo '<li class="row middle-school">'; | |
echo '<span class="muted left">'; | |
_e('Middle', 'contempo'); | |
echo '</span>'; | |
echo '<span class="right">'; | |
ct_idx_info('_ct_idx_schools_middle_school'); | |
echo '</span>'; | |
echo '</li>'; | |
} | |
if(!empty($ct_idx_schools_high_school)) { | |
echo '<li class="row high-school">'; | |
echo '<span class="muted left">'; | |
_e('High', 'contempo'); | |
echo '</span>'; | |
echo '<span class="right">'; | |
ct_idx_info('_ct_idx_schools_high_school'); | |
echo '</span>'; | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
echo '<div class="clear"></div>'; | |
echo '</div>'; | |
echo '<!-- //Listing IDX Schools -->'; | |
} | |
break; | |
} | |
} | |
} | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment