/** * Replicate compare function of the theme since I can't implement it in my own template */ function build_compare_table($atts) { $defaults = array('id' => get_the_ID(), 'before' => '', 'after' => '', 'empty' => 'true', 'wrap' => 'div'); extract(shortcode_atts($defaults, $atts)); // Open table $details = '<table class="table table-striped table-compare">'; // Add listing ID first $details .= '<tr class="listing-details-sc-detail table-compare-id">'; $details .= '<td class="table-compare-label">' . __('ID', 'wpsight') . ':</td>'; $details .= '<td class="table-compare-value">' . wpsight_get_listing_id() . '</td>'; $details .= '</tr><!-- .table-compare-id -->'; // Loop through standard details foreach (wpsight_standard_details() as $detail => $v) { // Don't show detail if label is emtpy in options $standard_details_option = wpsight_get_option($detail); if (empty($standard_details_option['label'])) { continue; } // Apply filter to optionally deactivate single detail if (apply_filters('wpsight_listing_details_table_' . $detail, true) != true) { continue; } $detail_meta = get_post_meta($id, '_' . $detail, true); if (!$detail_meta && $empty != 'true') { continue; } $detail_value = $detail_meta ? $detail_meta . ' ' . wpsight_get_measurement_units($v['unit']) : __('n/d', 'wpsight'); $details .= '<tr class="listing-details-sc-detail ' . $detail . '">'; $details .= '<td class="table-compare-label">' . $v['label'] . ':</td>'; $details .= '<td class="table-compare-value">' . $detail_value . '</td>'; $details .= '</tr><!-- .listing-details-sc-' . $detail . ' -->'; } // Add listing price at the end $details .= '<tr class="listing-details-sc-detail table-compare-price">'; $details .= '<td class="table-compare-value" colspan="2">' . wpsight_get_price() . '</td>'; $details .= '</tr><!-- .table-compare-price -->'; // Close table $details .= '</table><!-- .table-compare -->'; // $output = sprintf( '%1$s%3$s%2$s', $before, $after, $details ); // // Optionally wrap shortcode in HTML tags // if( ! empty( $wrap ) && $wrap != 'false' && in_array( $wrap, array_keys( wp_kses_allowed_html( 'post' ) ) ) ) // $output = sprintf( '<%2$s class="listing-details-table-sc">%1$s</%2$s>', $output, $wrap ); // return apply_filters( 'wpsight_listing_details_table_shortcode', $output, $atts ); return $details; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $listing_type = isset($instance['listing_type']) ? $instance['listing_type'] : true; $listing_location = isset($instance['listing_location']) ? $instance['listing_location'] : true; $listing_id = isset($instance['listing_id']) ? $instance['listing_id'] : true; // Loop through standard details foreach (wpsight_standard_details() as $key => $values) { $key = isset($instance[$key]) ? $instance[$key] : true; } if (is_single() && get_post_type() == wpsight_listing_post_type()) { ?> <div id="<?php echo wpsight_dashes($this->id); ?> " class="listing-details section clearfix clear"> <div class="title clearfix"> <div class="title-price listing-price"> <?php wpsight_price(); ?> </div> <?php // Action hook listing details title inside do_action('wpsight_listing_details_title_inside', $args, $instance); ?> </div><!-- .title --> <?php // Display details $standard_details = wpsight_standard_details(); $listing_details = ''; // Loop through standard details if (!empty($standard_details)) { $i = 0; $listing_details .= '<div class="row">' . "\n"; foreach ($standard_details as $feature => $value) { $standard_details_option = wpsight_get_option($feature); // If details hasn't been set before, display default if (!isset($standard_details_option['label'])) { $standard_details_option = wpsight_get_option($feature, true); } // Don't show detail if label is emtpy in options if (empty($standard_details_option['label'])) { continue; } // Append listing ID to details if ($i == 0 && $listing_id) { $listing_details_id = '<div class="' . wpsight_get_span('small') . '">' . "\n"; $listing_details_id .= '<span class="listing-details-label">' . __('Listing ID', 'wpsight') . ':</span>' . "\n"; $listing_details_id .= '<span class="listing-details-value">' . wpsight_get_listing_id(get_the_ID()) . '</span><!-- .listing-id-value -->' . "\n"; $listing_details_id .= '</div><!-- .listing-details-id -->' . "\n"; $listing_details .= apply_filters('wpsight_listing_details_id', $listing_details_id, $args, $instance); } $listing_details_value = get_post_meta(get_the_ID(), '_' . $feature, true); // Check if value is data key if (!empty($value['data'])) { $listing_details_value = $value['data'][$listing_details_value]; } $listing_details_meta = get_post_meta(get_the_ID(), '_' . $feature, true); if (!empty($listing_details_meta) && $instance[$feature]) { $listing_details .= '<div class="' . wpsight_get_span('small') . '">' . "\n"; $listing_details .= '<span class="listing-details-label">' . $value['label'] . ':</span><!-- .listing-' . $feature . '-label -->' . "\n"; $listing_details .= '<span class="listing-details-value">' . $listing_details_value . ' ' . wpsight_get_measurement_units($value['unit']) . '</span><!-- .listing-' . $feature . '-value -->' . "\n"; $listing_details .= '</div><!-- .listing-' . $feature . ' -->' . "\n"; } $i++; } // endforeach // Add date - will be hidden by CSS display:none $listing_details .= '<div class="' . wpsight_get_span('small') . '">' . "\n"; $listing_details .= '<span class="listing-date updated">' . get_the_date() . '</span>' . "\n"; $listing_details .= '</div>' . "\n"; $listing_details .= '</div><!-- .row -->' . "\n"; } // endif echo apply_filters('wpsight_widget_listing_details', $listing_details, $args, $instance); ?> </div><!-- .listing-details --><?php } }
function wpsight_get_listing_details($post_id = '', $details_nr = '', $details = false) { // Get post ID from $post_id if (empty($post_id)) { $post_id = get_the_ID(); } // If still empty, return false if (empty($post_id)) { return false; } // Get post custom data $post_custom = get_post_custom($post_id); // Get standard details $standard_details = wpsight_standard_details(); // Create markup $listing_details = '<div class="listing-details-overview clearfix">'; // Loop through details if (empty($details_nr)) { $details_nr = apply_filters('wpsight_get_listing_details_nr', 3); } // Check if specific details $details = apply_filters('wpsight_get_listing_details', $details); if (is_array($details)) { foreach ($details as $detail) { $pos = strpos($detail, '_'); if ($pos !== false && $pos == 0) { $detail = substr_replace($detail, '', $pos, strlen('_')); } if (!empty($post_custom['_' . $detail][0])) { $i = 1; // Get listing detail $listing_detail = wpsight_get_standard_detail($detail); $listing_details .= '<span class="listing-' . wpsight_dashes($detail) . ' listing-details-detail" title="' . $listing_detail['label'] . '">'; $listing_details .= $post_custom['_' . $detail][0] . ' '; $listing_details .= wpsight_get_measurement_units($standard_details[$detail]['unit']); $listing_details .= '</span><!-- .listing-' . wpsight_dashes($detail) . ' -->' . "\n"; $i++; } } } else { for ($i = 1; $i <= $details_nr; $i++) { if (!isset($post_custom['_details_' . $i][0])) { continue; } $listing_detail_value = $post_custom['_details_' . $i][0]; if (!empty($listing_detail_value)) { // Get listing detail $listing_detail = wpsight_get_standard_detail('details_' . $i); $listing_details .= '<span class="listing-details-' . $i . ' listing-details-detail" title="' . $listing_detail['label'] . '">'; // Check if value is data key if (!empty($listing_detail['data'])) { $listing_detail_value = $listing_detail['data'][$listing_detail_value]; } $listing_details .= $listing_detail_value . ' '; $listing_details .= wpsight_get_measurement_units($standard_details['details_' . $i]['unit']); $listing_details .= '</span><!-- .listing-details-' . $i . ' -->' . "\n"; } } } // Display formatted listing price $listing_details .= '<span class="listing-price">' . wpsight_get_price($post_id) . '</span><!-- .listing-price -->' . "\n"; // Close markup $listing_details .= '</div><!-- .listing-details -->'; return apply_filters('wpsight_listing_details', $listing_details); }
function wpcasa_get_measurement_units($unit) { return wpsight_get_measurement_units($unit); }
function widget($args, $instance) { extract($args, EXTR_SKIP); $property_type = isset($instance['property_type']) ? $instance['property_type'] : true; $property_location = isset($instance['property_location']) ? $instance['property_location'] : true; $property_id = isset($instance['property_id']) ? $instance['property_id'] : true; /** Loop through standard details */ foreach (wpsight_standard_details() as $key => $values) { $key = isset($instance[$key]) ? $instance[$key] : true; } if (is_single() && get_post_type() == 'property') { ?> <div id="<?php echo wpsight_dashes($args['widget_id']); ?> " class="listing-details listing-details section clearfix clear"> <div class="title clearfix"> <div class="title-price property-price listing-price"> <?php wpsight_price(); ?> </div> <?php // Action hook property details title inside do_action('wpsight_listing_details_title_inside', $args, $instance); ?> </div><!-- .title --> <?php // Display details $standard_details = wpsight_standard_details(); $property_details = ''; // Loop through standard details if (!empty($standard_details)) { $i = 0; $property_details .= '<div class="row">' . "\n"; foreach ($standard_details as $feature => $value) { // Append property ID to details if ($i == 0 && $property_id) { $property_details_id = '<div class="' . wpsight_get_span('small') . '">' . "\n"; $property_details_id .= '<span class="listing-details-label">' . __('Property ID', 'wpsight') . ':</span>' . "\n"; $property_details_id .= '<span class="listing-details-value">' . wpsight_get_listing_id(get_the_ID()) . '</span><!-- .listing-id-value -->' . "\n"; $property_details_id .= '</div><!-- .listing-details-id -->' . "\n"; $property_details .= apply_filters('wpsight_listing_details_id', $property_details_id); } $property_details_value = get_post_meta(get_the_ID(), '_' . $feature, true); if (!empty($property_details_value) && $instance[$feature]) { $property_details .= '<div class="' . wpsight_get_span('small') . '">' . "\n"; $property_details .= '<span class="listing-details-label">' . $value['label'] . ':</span><!-- .listing-' . $feature . '-label -->' . "\n"; $property_details .= '<span class="listing-details-value">' . $property_details_value . ' ' . wpsight_get_measurement_units($value['unit']) . '</span><!-- .listing-' . $feature . '-value -->' . "\n"; $property_details .= '</div><!-- .property-' . $feature . ' -->' . "\n"; } $i++; } // endforeach // Add date - will be hidden by CSS display:none $property_details .= '<div class="' . wpsight_get_span('small') . '">' . "\n"; $property_details .= '<span class="listing-date updated">' . get_the_date() . '</span>' . "\n"; $property_details .= '</div>' . "\n"; $property_details .= '</div><!-- .row -->' . "\n"; } // endif echo apply_filters('wpsight_widget_listing_details', $property_details); ?> </div><!-- .listing-details --><?php } }