function wpsight_listings_custom_columns($column) { $post_id = get_the_ID(); switch ($column) { case 'listing_details': echo '<strong>ID: </strong>' . wpsight_get_listing_id($post_id) . '<br />'; echo __('Location', 'wpsight') . ': ' . get_the_term_list($post_id, 'location', '', ', ', '') . '<br />'; if (taxonomy_exists('property-type')) { echo __('Type', 'wpsight') . ': ' . get_the_term_list($post_id, 'property-type', '', ', ', '') . '<br />'; } if (has_term('', 'listing-category', $post_id)) { echo __('Category', 'wpsight') . ': ' . get_the_term_list($post_id, 'listing-category', '', ', ', ''); } if (has_term('', 'property-category', $post_id)) { echo __('Category', 'wpsight') . ': ' . get_the_term_list($post_id, 'property-category', '', ', ', ''); } break; case 'listing_price': echo wpsight_get_price(); break; case 'listing_agent': echo get_the_author(); if (current_user_can('edit_users')) { echo '<br /><a href="' . admin_url('user-edit.php?user_id=' . get_the_author_meta('ID'), 'http') . '">' . __('See profile', 'wpsight') . '</a>'; } break; case 'listing_features': echo get_the_term_list($post_id, 'feature', '', ', ', '') . '<br />'; break; case 'listing_image': echo get_the_post_thumbnail($post_id, 'thumbnail'); break; } }
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 } }
/** * 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 wpcasa_get_property_id($id) { wpsight_get_listing_id($id); }
/** * Echo listing ID * * @since 1.0 */ function wpsight_listing_id($post_id = '') { echo wpsight_get_listing_id($post_id); }
function wpsight_contact_field_favorites($fields) { if (!isset($_GET['fav']) || $_GET['fav'] != '1' || empty($_COOKIE[WPSIGHT_COOKIE_FAVORITES])) { return $fields; } // Get listing IDs stored in cookie $favorites = explode(',', $_COOKIE[WPSIGHT_COOKIE_FAVORITES]); $data = array(); foreach ($favorites as $favorite) { // Check if listing publish if (get_post_status($favorite) != 'publish') { continue; } $data[$favorite] = '<strong>' . wpsight_get_listing_id($favorite) . ':</strong> <a href="' . get_permalink($favorite) . '">' . get_the_title($favorite) . '</a>'; } $fields['favorites'] = array('id' => 'favorites', 'label' => __('Your favorites', 'wpsight'), 'required' => false, 'type' => 'checkbox', 'placeholder' => false, 'before' => false, 'after' => '<div class="description">' . __('Please check the listings you wish to receive information about', 'wpsight') . '</div>', 'value' => $favorites, 'data' => $data, 'position' => 35); return $fields; }
function wpsight_listing_id_default($post_id, $post) { if ($post->post_status != 'auto-draft' || $post->post_type != wpsight_listing_post_type()) { return; } $listing_id = get_post_meta($post->ID, '_listing_id', true); if (!$listing_id) { update_post_meta($post->ID, '_listing_id', wpsight_get_listing_id($post->ID)); } }
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 } }