function widget($args, $instance) { extract($args); $column_class = $instance['use_columns'] ? $this->get_column_class($instance['number_columns']) : ''; echo $before_widget; if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } if (!empty($instance['posts_term'])) { $posts_term = explode(',', $instance['posts_term']); } $query_args = array('post_type' => 'listing', 'posts_per_page' => $instance['posts_per_page'], 'paged' => get_query_var('paged') ? get_query_var('paged') : 1); if (!empty($instance['posts_term']) && count($posts_term) == 2) { $query_args[$posts_term['0']] = $posts_term['1']; } $wp_listings_widget_query = new WP_Query($query_args); $count = 0; global $post; if ($wp_listings_widget_query->have_posts()) { while ($wp_listings_widget_query->have_posts()) { $wp_listings_widget_query->the_post(); $count = $count == $instance['number_columns'] ? 1 : $count + 1; $first_class = 1 == $count && 1 == $instance['use_columns'] ? ' first' : ''; $loop = sprintf('<div class="listing-widget-thumb"><a href="%s" class="listing-image-link">%s</a>', get_permalink(), get_the_post_thumbnail($post->ID, $instance['image_size'])); if ('' != wp_listings_get_status()) { $loop .= sprintf('<span class="listing-status %s">%s</span>', strtolower(str_replace(' ', '-', wp_listings_get_status())), wp_listings_get_status()); } $loop .= sprintf('<div class="listing-thumb-meta">'); if ('' != get_post_meta($post->ID, '_listing_text', true)) { $loop .= sprintf('<span class="listing-text">%s</span>', get_post_meta($post->ID, '_listing_text', true)); } elseif ('' != wp_listings_get_property_types()) { $loop .= sprintf('<span class="listing-property-type">%s</span>', wp_listings_get_property_types()); } if ('' != get_post_meta($post->ID, '_listing_price', true)) { $loop .= sprintf('<span class="listing-price">%s</span>', get_post_meta($post->ID, '_listing_price', true)); } $loop .= sprintf('</div><!-- .listing-thumb-meta --></div><!-- .listing-widget-thumb -->'); if ('' != get_post_meta($post->ID, '_listing_open_house', true)) { $loop .= sprintf('<span class="listing-open-house">Open House: %s</span>', get_post_meta($post->ID, '_listing_open_house', true)); } $loop .= sprintf('<div class="listing-widget-details"><h3 class="listing-title"><a href="%s">%s</a></h3>', get_permalink(), get_the_title()); $loop .= sprintf('<p class="listing-address"><span class="listing-address">%s</span><br />', wp_listings_get_address()); $loop .= sprintf('<span class="listing-city-state-zip">%s, %s %s</span></p>', wp_listings_get_city(), wp_listings_get_state(), get_post_meta($post->ID, '_listing_zip', true)); if ('' != get_post_meta($post->ID, '_listing_bedrooms', true) || '' != get_post_meta($post->ID, '_listing_bathrooms', true) || '' != get_post_meta($post->ID, '_listing_sqft', true)) { $loop .= sprintf('<ul class="listing-beds-baths-sqft"><li class="beds">%s<span>Beds</span></li> <li class="baths">%s<span>Baths</span></li> <li class="sqft">%s<span>Sq ft</span></li></ul>', get_post_meta($post->ID, '_listing_bedrooms', true), get_post_meta($post->ID, '_listing_bathrooms', true), get_post_meta($post->ID, '_listing_sqft', true)); } $loop .= sprintf('</div><!-- .listing-widget-details -->'); $loop .= sprintf('<a href="%s" class="button btn-primary more-link">%s</a>', get_permalink(), __('View Listing', 'wp_listings')); /** wrap in div with possible column class, and output **/ printf('<div class="listing %s post-%s"><div class="listing-wrap">%s</div></div>', $column_class . $first_class, $post->ID, apply_filters('wp_listings_featured_listings_widget_loop', $loop)); } } wp_reset_postdata(); echo $after_widget; }
/** * The template for displaying Listing Archive pages * * @link http://codex.wordpress.org/Template_Hierarchy * * @package WP Listings * @since 0.1.0 */ function archive_listing_loop() { global $post; $count = 0; // start counter at 0 // Uncomment to use term image in your theme // echo '<div class="wp-listings-term-image">' . wp_listings_term_image(get_queried_object()->term_id, true, 'full') . '</div>'; // Start the Loop. while (have_posts()) { the_post(); $count++; // add 1 to counter on each loop $first = $count == 1 ? 'first' : ''; // if counter is 1 add class of first $loop = sprintf('<div class="listing-widget-thumb"><a href="%s" class="listing-image-link">%s</a>', get_permalink(), get_the_post_thumbnail($post->ID, 'listings')); if ('' != wp_listings_get_status()) { $loop .= sprintf('<span class="listing-status %s">%s</span>', strtolower(str_replace(' ', '-', wp_listings_get_status($post->ID, 1))), wp_listings_get_status()); } $loop .= sprintf('<div class="listing-thumb-meta">'); if ('' != get_post_meta($post->ID, '_listing_text', true)) { $loop .= sprintf('<span class="listing-text">%s</span>', get_post_meta($post->ID, '_listing_text', true)); } elseif ('' != wp_listings_get_property_types()) { $loop .= sprintf('<span class="listing-property-type">%s</span>', wp_listings_get_property_types()); } if ('' != get_post_meta($post->ID, '_listing_price', true)) { $loop .= sprintf('<span class="listing-price">%s</span>', get_post_meta($post->ID, '_listing_price', true)); } $loop .= sprintf('</div><!-- .listing-thumb-meta --></div><!-- .listing-widget-thumb -->'); if ('' != get_post_meta($post->ID, '_listing_open_house', true)) { $loop .= sprintf('<span class="listing-open-house">Open House: %s</span>', get_post_meta($post->ID, '_listing_open_house', true)); } $loop .= sprintf('<div class="listing-widget-details"><h3 class="listing-title"><a href="%s">%s</a></h3>', get_permalink(), get_the_title()); $loop .= sprintf('<p class="listing-address"><span class="listing-address">%s</span><br />', wp_listings_get_address()); $loop .= sprintf('<span class="listing-city-state-zip">%s, %s %s</span></p>', wp_listings_get_city(), wp_listings_get_state(), get_post_meta($post->ID, '_listing_zip', true)); if ('' != get_post_meta($post->ID, '_listing_bedrooms', true) || '' != get_post_meta($post->ID, '_listing_bathrooms', true) || '' != get_post_meta($post->ID, '_listing_sqft', true)) { $loop .= sprintf('<ul class="listing-beds-baths-sqft"><li class="beds">%s<span>Beds</span></li> <li class="baths">%s<span>Baths</span></li> <li class="sqft">%s<span>Sq ft</span></li></ul>', get_post_meta($post->ID, '_listing_bedrooms', true), get_post_meta($post->ID, '_listing_bathrooms', true), get_post_meta($post->ID, '_listing_sqft', true)); } $loop .= sprintf('</div><!-- .listing-widget-details -->'); $loop .= sprintf('<a href="%s" class="button btn-primary more-link">%s</a>', get_permalink(), __('View Listing', 'wp_listings')); /** wrap in div with column class, and output **/ printf('<article id="post-%s" class="listing entry one-third %s"><div class="listing-wrap">%s</div><!-- .listing-wrap --></article><!-- article#post-## -->', get_the_id(), $first, apply_filters('wp_listings_featured_listings_widget_loop', $loop)); if (3 == $count) { // if counter is 3, reset to 0 $count = 0; } } if (function_exists('equity')) { equity_posts_nav(); } elseif (function_exists('genesis_init')) { genesis_posts_nav(); } else { wp_listings_paging_nav(); } }
function wp_listings_shortcode($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'taxonomy' => '', 'term' => '', 'limit' => '', 'columns' => ''), $atts)); /** * if limit is empty set to all */ if (!$limit) { $limit = -1; } /** * if columns is empty set to 0 */ if (!$columns) { $columns = 0; } /* * query args based on parameters */ $query_args = array('post_type' => 'listing', 'posts_per_page' => $limit); if ($id) { $query_args = array('post_type' => 'listing', 'post__in' => explode(',', $id)); } if ($term && $taxonomy) { $query_args = array('post_type' => 'listing', 'posts_per_page' => $limit, 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term))); } /* * start loop */ global $post; $listings_array = get_posts($query_args); $count = 0; $output = '<div class="wp-listings-shortcode">'; foreach ($listings_array as $post) { setup_postdata($post); $count = $count == $columns ? 1 : $count + 1; $first_class = 1 == $count ? 'first' : ''; $output .= '<div class="listing-wrap ' . get_column_class($columns) . ' ' . $first_class . '"><div class="listing-widget-thumb"><a href="' . get_permalink() . '" class="listing-image-link">' . get_the_post_thumbnail($post->ID, 'listings') . '</a>'; if ('' != wp_listings_get_status()) { $output .= '<span class="listing-status ' . strtolower(str_replace(' ', '-', wp_listings_get_status())) . '">' . wp_listings_get_status() . '</span>'; } $output .= '<div class="listing-thumb-meta">'; if ('' != get_post_meta($post->ID, '_listing_text', true)) { $output .= '<span class="listing-text">' . get_post_meta($post->ID, '_listing_text', true) . '</span>'; } elseif ('' != wp_listings_get_property_types()) { $output .= '<span class="listing-property-type">' . wp_listings_get_property_types() . '</span>'; } if ('' != get_post_meta($post->ID, '_listing_price', true)) { $output .= '<span class="listing-price">' . get_post_meta($post->ID, '_listing_price', true) . '</span>'; } $output .= '</div><!-- .listing-thumb-meta --></div><!-- .listing-widget-thumb -->'; if ('' != get_post_meta($post->ID, '_listing_open_house', true)) { $output .= '<span class="listing-open-house">' . __("Open House", 'wp_listings') . ': ' . get_post_meta($post->ID, '_listing_open_house', true) . '</span>'; } $output .= '<div class="listing-widget-details"><h3 class="listing-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>'; $output .= '<p class="listing-address"><span class="listing-address">' . wp_listings_get_address() . '</span><br />'; $output .= '<span class="listing-city-state-zip">' . wp_listings_get_city() . ', ' . wp_listings_get_state() . ' ' . get_post_meta($post->ID, '_listing_zip', true) . '</span></p>'; if ('' != get_post_meta($post->ID, '_listing_bedrooms', true) || '' != get_post_meta($post->ID, '_listing_bathrooms', true) || '' != get_post_meta($post->ID, '_listing_sqft', true)) { $output .= '<ul class="listing-beds-baths-sqft"><li class="beds">' . get_post_meta($post->ID, '_listing_bedrooms', true) . '<span>' . __("Beds", 'wp_listings') . '</span></li> <li class="baths">' . get_post_meta($post->ID, '_listing_bathrooms', true) . '<span>' . __("Baths", 'wp_listings') . '</span></li> <li class="sqft">' . get_post_meta($post->ID, '_listing_sqft', true) . '<span>' . __("Square Feet", 'wp_listings') . '</span></li></ul>'; } $output .= '</div><!-- .listing-widget-details --></div><!-- .listing-wrap -->'; } $output .= '</div><!-- .wp-listings-shortcode -->'; wp_reset_postdata(); return $output; }
function single_listing_post_content() { global $post; ?> <div itemscope itemtype="http://schema.org/SingleFamilyResidence" class="entry-content wplistings-single-listing"> <div class="listing-image-wrap"> <?php echo '<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">' . get_the_post_thumbnail($post->ID, 'listings-full', array('class' => 'single-listing-image', 'itemprop' => 'contentUrl')) . '</div>'; if ('' != wp_listings_get_status()) { printf('<span class="listing-status %s">%s</span>', strtolower(str_replace(' ', '-', wp_listings_get_status())), wp_listings_get_status()); } if ('' != get_post_meta($post->ID, '_listing_open_house', true)) { printf('<span class="listing-open-house">Open House: %s</span>', get_post_meta($post->ID, '_listing_open_house', true)); } ?> </div><!-- .listing-image-wrap --> <?php $listing_meta = sprintf('<ul class="listing-meta">'); if (get_post_meta($post->ID, '_listing_hide_price', true) == 1) { $listing_meta .= get_post_meta($post->ID, '_listing_price_alt', true) ? sprintf('<li class="listing-price">%s</li>', get_post_meta($post->ID, '_listing_price_alt', true)) : ''; } else { $listing_meta .= sprintf('<li class="listing-price">%s</li>', get_post_meta($post->ID, '_listing_price', true)); } if ('' != wp_listings_get_property_types()) { $listing_meta .= sprintf('<li class="listing-property-type"><span class="label">Property Type: </span>%s</li>', get_the_term_list(get_the_ID(), 'property-types', '', ', ', '')); } if ('' != wp_listings_get_locations()) { $listing_meta .= sprintf('<li class="listing-location"><span class="label">Location: </span>%s</li>', get_the_term_list(get_the_ID(), 'locations', '', ', ', '')); } if ('' != get_post_meta($post->ID, '_listing_bedrooms', true)) { $listing_meta .= sprintf('<li class="listing-bedrooms"><span class="label">Beds: </span>%s</li>', get_post_meta($post->ID, '_listing_bedrooms', true)); } if ('' != get_post_meta($post->ID, '_listing_bathrooms', true)) { $listing_meta .= sprintf('<li class="listing-bathrooms"><span class="label">Baths: </span>%s</li>', get_post_meta($post->ID, '_listing_bathrooms', true)); } if ('' != get_post_meta($post->ID, '_listing_sqft', true)) { $listing_meta .= sprintf('<li class="listing-sqft"><span class="label">Sq Ft: </span>%s</li>', get_post_meta($post->ID, '_listing_sqft', true)); } if ('' != get_post_meta($post->ID, '_listing_lot_sqft', true)) { $listing_meta .= sprintf('<li class="listing-lot-sqft"><span class="label">Lot Sq Ft: </span>%s</li>', get_post_meta($post->ID, '_listing_lot_sqft', true)); } $listing_meta .= sprintf('</ul>'); echo $listing_meta; ?> <div id="listing-tabs" class="listing-data"> <ul> <li><a href="#listing-description">Description</a></li> <li><a href="#listing-details">Details</a></li> <?php if (get_post_meta($post->ID, '_listing_gallery', true) != '') { ?> <li><a href="#listing-gallery">Photos</a></li> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_video', true) != '') { ?> <li><a href="#listing-video">Video / Virtual Tour</a></li> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_school_neighborhood', true) != '') { ?> <li><a href="#listing-school-neighborhood">Schools & Neighborhood</a></li> <?php } ?> </ul> <div id="listing-description" itemprop="description"> <?php the_content(__('View more <span class="meta-nav">→</span>', 'wp_listings')); echo get_post_meta($post->ID, '_listing_featured_on', true) ? '<p class="wp_listings_featured_on">' . get_post_meta($post->ID, '_listing_featured_on', true) . '</p>' : ''; echo get_post_meta($post->ID, '_listing_disclaimer', true) ? '<p class="wp_listings_disclaimer">' . get_post_meta($post->ID, '_listing_disclaimer', true) . '</p>' : ''; echo get_post_meta($post->ID, '_listing_courtesy', true) ? '<p class="wp_listings_courtesy">' . get_post_meta($post->ID, '_listing_courtesy', true) . '</p>' : ''; ?> </div><!-- #listing-description --> <div id="listing-details"> <?php $details_instance = new WP_Listings(); $pattern = '<tr class="wp_listings%s"><td class="label">%s</td><td>%s</td></tr>'; echo '<table class="listing-details">'; echo '<tbody class="left">'; if (get_post_meta($post->ID, '_listing_hide_price', true) == 1) { echo get_post_meta($post->ID, '_listing_price_alt', true) ? '<tr class="wp_listings_listing_price"><td class="label">' . __('Price:', 'wp_listings') . '</td><td>' . get_post_meta($post->ID, '_listing_price_alt', true) . '</td></tr>' : ''; } else { echo get_post_meta($post->ID, '_listing_price', true) ? '<tr class="wp_listings_listing_price"><td class="label">' . __('Price:', 'wp_listings') . '</td><td>' . get_post_meta($post->ID, '_listing_price', true) . '</td></tr>' : ''; } echo '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; echo get_post_meta($post->ID, '_listing_address', true) ? '<tr class="wp_listings_listing_address"><td class="label">' . __('Address:', 'wp_listings') . '</td><td itemprop="streetAddress">' . get_post_meta($post->ID, '_listing_address', true) . '</td></tr>' : ''; echo get_post_meta($post->ID, '_listing_city', true) ? '<tr class="wp_listings_listing_city"><td class="label">' . __('City:', 'wp_listings') . '</td><td itemprop="addressLocality">' . get_post_meta($post->ID, '_listing_city', true) . '</td></tr>' : ''; echo get_post_meta($post->ID, '_listing_state', true) ? '<tr class="wp_listings_listing_state"><td class="label">' . __('State:', 'wp_listings') . '</td><td itemprop="addressRegion">' . get_post_meta($post->ID, '_listing_state', true) . '</td></tr>' : ''; echo get_post_meta($post->ID, '_listing_zip', true) ? '<tr class="wp_listings_listing_zip"><td class="label">' . __('Zip Code:', 'wp_listings') . '</td><td itemprop="postalCode">' . get_post_meta($post->ID, '_listing_zip', true) . '</td></tr>' : ''; echo '</div>'; echo get_post_meta($post->ID, '_listing_mls', true) ? '<tr class="wp_listings_listing_mls"><td class="label">MLS:</td><td>' . get_post_meta($post->ID, '_listing_mls', true) . '</td></tr>' : ''; echo '</tbody>'; echo '<tbody class="right">'; foreach ((array) $details_instance->property_details['col2'] as $label => $key) { $detail_value = esc_html(get_post_meta($post->ID, $key, true)); if (!empty($detail_value)) { printf($pattern, $key, esc_html($label), $detail_value); } } echo '</tbody>'; echo '</table>'; echo '<table class="listing-details extended">'; echo '<tbody class="left">'; foreach ((array) $details_instance->extended_property_details['col1'] as $label => $key) { $detail_value = esc_html(get_post_meta($post->ID, $key, true)); if (!empty($detail_value)) { printf($pattern, $key, esc_html($label), $detail_value); } } echo '</tbody>'; echo '<tbody class="right">'; foreach ((array) $details_instance->extended_property_details['col2'] as $label => $key) { $detail_value = esc_html(get_post_meta($post->ID, $key, true)); if (!empty($detail_value)) { printf($pattern, $key, esc_html($label), $detail_value); } } echo '</tbody>'; echo '</table>'; if (get_the_term_list(get_the_ID(), 'features', '<li>', '</li><li>', '</li>') != null) { echo '<h5>' . __('Tagged Features:', 'wp_listings') . '</h5><ul class="tagged-features">'; echo get_the_term_list(get_the_ID(), 'features', '<li>', '</li><li>', '</li>'); echo '</ul><!-- .tagged-features -->'; } if (get_post_meta($post->ID, '_listing_home_sum', true) != '' || get_post_meta($post->ID, '_listing_kitchen_sum', true) != '' || get_post_meta($post->ID, '_listing_living_room', true) != '' || get_post_meta($post->ID, '_listing_master_suite', true) != '') { ?> <div class="additional-features"> <h4>Additional Features</h4> <h6 class="label"><?php _e("Home Summary", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_home_sum', true)); ?> </p> <h6 class="label"><?php _e("Kitchen Summary", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_kitchen_sum', true)); ?> </p> <h6 class="label"><?php _e("Living Room", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_living_room', true)); ?> </p> <h6 class="label"><?php _e("Master Suite", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_master_suite', true)); ?> </p> </div><!-- .additional-features --> <?php } ?> </div><!-- #listing-details --> <?php if (get_post_meta($post->ID, '_listing_gallery', true) != '') { ?> <div id="listing-gallery"> <?php echo do_shortcode(get_post_meta($post->ID, '_listing_gallery', true)); ?> </div><!-- #listing-gallery --> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_video', true) != '') { ?> <div id="listing-video"> <div class="iframe-wrap"> <?php echo get_post_meta($post->ID, '_listing_video', true); ?> </div> </div><!-- #listing-video --> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_school_neighborhood', true) != '') { ?> <div id="listing-school-neighborhood"> <p> <?php echo do_shortcode(get_post_meta($post->ID, '_listing_school_neighborhood', true)); ?> </p> </div><!-- #listing-school-neighborhood --> <?php } ?> </div><!-- #listing-tabs.listing-data --> <?php if (get_post_meta($post->ID, '_listing_map', true) != '') { echo '<div id="listing-map"><h3>Location Map</h3>'; echo do_shortcode(get_post_meta($post->ID, '_listing_map', true)); echo '</div><!-- .listing-map -->'; } elseif (get_post_meta($post->ID, '_listing_latitude', true) && get_post_meta($post->ID, '_listing_longitude', true) && get_post_meta($post->ID, '_listing_automap', true) == 'y') { $map_info_content = sprintf('<p style="font-size: 14px; margin-bottom: 0;">%s<br />%s %s, %s</p>', get_post_meta($post->ID, '_listing_address', true), get_post_meta($post->ID, '_listing_city', true), get_post_meta($post->ID, '_listing_state', true), get_post_meta($post->ID, '_listing_zip', true)); echo '<script src="https://maps.googleapis.com/maps/api/js"></script> <script> function initialize() { var mapCanvas = document.getElementById(\'map-canvas\'); var myLatLng = new google.maps.LatLng(' . get_post_meta($post->ID, '_listing_latitude', true) . ', ' . get_post_meta($post->ID, '_listing_longitude', true) . ') var mapOptions = { center: myLatLng, zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP } var marker = new google.maps.Marker({ position: myLatLng, icon: \'//s3.amazonaws.com/ae-plugins/wp-listings/images/active.png\' }); var infoContent = \' ' . $map_info_content . ' \'; var infowindow = new google.maps.InfoWindow({ content: infoContent }); var map = new google.maps.Map(mapCanvas, mapOptions); marker.setMap(map); infowindow.open(map, marker); } google.maps.event.addDomListener(window, \'load\', initialize); </script> '; echo '<div id="listing-map"><h3>Location Map</h3><div id="map-canvas" style="width: 100%; height: 350px;"></div></div><!-- .listing-map -->'; } ?> <?php if (function_exists('_p2p_init') && function_exists('agent_profiles_init')) { echo '<div id="listing-agent"> <div class="connected-agents">'; aeprofiles_connected_agents_markup(); echo '</div></div><!-- .listing-agent -->'; } elseif (function_exists('_p2p_init') && function_exists('impress_agents_init')) { echo '<div id="listing-agent"> <div class="connected-agents">'; impa_connected_agents_markup(); echo '</div></div><!-- .listing-agent -->'; } ?> <div id="listing-contact"> <?php $options = get_option('plugin_wp_listings_settings'); if (get_post_meta($post->ID, '_listing_contact_form', true) != '') { echo do_shortcode(get_post_meta($post->ID, '_listing_contact_form', true)); } elseif (isset($options['wp_listings_default_form']) && $options['wp_listings_default_form'] != '') { echo do_shortcode($options['wp_listings_default_form']); } else { echo '<h4>Listing Inquiry</h4>'; $nameError = ''; $emailError = ''; $response = ''; if (isset($_POST['submitted'])) { $url = get_permalink(); $listing = get_the_title(); if (trim($_POST['contactName']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = esc_html(trim($_POST['contactName'])); } if (trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else { if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\\.[a-z]{2,4}\$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = esc_html(trim($_POST['email'])); } } $phone = esc_html(trim($_POST['phone'])); if (function_exists('stripslashes')) { $comments = esc_html(stripslashes(trim($_POST['comments']))); } else { $comments = esc_html(trim($_POST['comments'])); } if ($options['wp_listings_captcha_site_key'] != '' && $options['wp_listings_captcha_secret_key'] != '') { require_once WP_LISTINGS_DIR . '/includes/class-recaptcha.php'; // your secret key $secret = $options['wp_listings_captcha_secret_key']; // empty response $response = null; // check secret key $reCaptcha = new ReCaptcha($secret); if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); } } if (isset($_POST['antispam']) && $_POST['antispam'] == '' || $response != null && $response->success) { if (!isset($hasError)) { $emailTo = get_the_author_meta('user_email', $post->post_author); if (!isset($emailTo) || $emailTo == '') { $emailTo = get_option('admin_email'); } $subject = 'Listing Inquiry from ' . $name; $body = "Name: {$name} \n\nEmail: {$email} \n\nPhone: {$phone} \n\nListing: {$listing} \n\nURL: {$url} \n\nComments: {$comments}"; $headers = 'From: ' . $name . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); $emailSent = true; } } else { $emailSent = true; // make spammer think message went through } } ?> <?php if (isset($emailSent) && $emailSent == true) { ?> <div class="thanks"> <a name="redirectTo"></a> <p>Thanks, your email was sent! We'll be in touch shortly.</p> </div> <?php } else { ?> <?php if (isset($hasError)) { ?> <a name="redirectTo"></a> <label class="error" name="redirectTo">Sorry, an error occured. Please try again.<label> <?php } ?> <form action="<?php the_permalink(); ?> #redirectTo" id="inquiry-form" method="post"> <ul class="inquiry-form"> <li class="contactName"> <label for="contactName">Name: <span class="required">*</span></label> <input type="text" name="contactName" id="contactName" value="<?php if (isset($_POST['contactName'])) { echo esc_html($_POST['contactName']); } ?> " class="required requiredField" /> <?php if ($nameError != '') { ?> <label class="error"><?php echo $nameError; ?> </label> <?php } ?> </li> <li class="contactEmail"> <label for="email">Email: <span class="required">*</span></label> <input type="text" name="email" id="email" value="<?php if (isset($_POST['email'])) { echo esc_html($_POST['email']); } ?> " class="required requiredField email" /> <?php if ($emailError != '') { ?> <label class="error"><?php echo $emailError; ?> </label> <?php } ?> </li> <li class="contactPhone"> <label for="phone">Phone:</label> <input type="text" name="phone" id="phone" value="<?php if (isset($_POST['phone'])) { echo esc_html($_POST['phone']); } ?> " /> </li> <li class="contactComments"><label for="commentsText">Message:</label> <textarea name="comments" id="commentsText" rows="6" cols="20"><?php if (isset($_POST['comments'])) { echo esc_html($_POST['comments']); } ?> </textarea> </li> <?php if ($options['wp_listings_captcha_site_key'] != '' && $options['wp_listings_captcha_secret_key'] != '') { echo '<div class="g-recaptcha" data-sitekey="' . $options['wp_listings_captcha_site_key'] . '"></div>'; echo '<script src="https://www.google.com/recaptcha/api.js"></script>'; } else { echo '<li> <input style="display: none;" type="text" name="antispam" /> </li>'; } ?> <li> <input id="submit" type="submit" value="Send Inquiry"></input> </li> </ul> <input type="hidden" name="submitted" id="submitted" value="true" /> </form> <?php } } ?> </div><!-- .listing-contact --> </div><!-- .entry-content --> <?php }
function single_listing_post_content() { global $post; ?> <div class="entry-content wplistings-single-listing"> <div class="listing-image-wrap"> <?php echo get_the_post_thumbnail($post->ID, 'listings-full', array('class' => 'single-listing-image')); if ('' != wp_listings_get_status()) { printf('<span class="listing-status %s">%s</span>', strtolower(str_replace(' ', '-', wp_listings_get_status())), wp_listings_get_status()); } if ('' != get_post_meta($post->ID, '_listing_open_house', true)) { printf('<span class="listing-open-house">Open House: %s</span>', get_post_meta($post->ID, '_listing_open_house', true)); } ?> </div><!-- .listing-image-wrap --> <?php $listing_meta = sprintf('<ul class="listing-meta">'); if ('' != get_post_meta($post->ID, '_listing_price', true)) { $listing_meta .= sprintf('<li class="listing-price">%s</li>', get_post_meta($post->ID, '_listing_price', true)); } if ('' != wp_listings_get_property_types()) { $listing_meta .= sprintf('<li class="listing-property-type"><span class="label">Property Type: </span>%s</li>', get_the_term_list(get_the_ID(), 'property-types', '', ', ', '')); } if ('' != wp_listings_get_locations()) { $listing_meta .= sprintf('<li class="listing-location"><span class="label">Location: </span>%s</li>', get_the_term_list(get_the_ID(), 'locations', '', ', ', '')); } if ('' != get_post_meta($post->ID, '_listing_bedrooms', true)) { $listing_meta .= sprintf('<li class="listing-bedrooms"><span class="label">Beds: </span>%s</li>', get_post_meta($post->ID, '_listing_bedrooms', true)); } if ('' != get_post_meta($post->ID, '_listing_bathrooms', true)) { $listing_meta .= sprintf('<li class="listing-bathrooms"><span class="label">Baths: </span>%s</li>', get_post_meta($post->ID, '_listing_bathrooms', true)); } if ('' != get_post_meta($post->ID, '_listing_sqft', true)) { $listing_meta .= sprintf('<li class="listing-sqft"><span class="label">Sq Ft: </span>%s</li>', get_post_meta($post->ID, '_listing_sqft', true)); } if ('' != get_post_meta($post->ID, '_listing_lot_sqft', true)) { $listing_meta .= sprintf('<li class="listing-lot-sqft"><span class="label">Lot Sq Ft: </span>%s</li>', get_post_meta($post->ID, '_listing_lot_sqft', true)); } $listing_meta .= sprintf('</ul>'); echo $listing_meta; ?> <div id="listing-tabs" class="listing-data"> <ul> <li><a href="#listing-description">Description</a></li> <li><a href="#listing-details">Details</a></li> <?php if (get_post_meta($post->ID, '_listing_gallery', true) != '') { ?> <li><a href="#listing-gallery">Photos</a></li> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_video', true) != '') { ?> <li><a href="#listing-video">Video / Virtual Tour</a></li> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_school_neighborhood', true) != '') { ?> <li><a href="#listing-school-neighborhood">Schools & Neighborhood</a></li> <?php } ?> </ul> <div id="listing-description"> <?php the_content(__('View more <span class="meta-nav">→</span>', 'wp_listings')); ?> </div><!-- #listing-description --> <div id="listing-details"> <?php $details_instance = new WP_Listings(); $pattern = '<tr class="wp_listings%s"><td class="label">%s</td><td>%s</td></tr>'; echo '<table class="listing-details">'; echo '<tbody class="left">'; foreach ((array) $details_instance->property_details['col1'] as $label => $key) { $detail_value = esc_html(get_post_meta($post->ID, $key, true)); if (!empty($detail_value)) { printf($pattern, $key, esc_html($label), $detail_value); } } echo '</tbody>'; echo '<tbody class="right">'; foreach ((array) $details_instance->property_details['col2'] as $label => $key) { $detail_value = esc_html(get_post_meta($post->ID, $key, true)); if (!empty($detail_value)) { printf($pattern, $key, esc_html($label), $detail_value); } } echo '</tbody>'; echo '</table>'; echo '<h5>Tagged Features</h5><ul class="tagged-features">'; echo get_the_term_list(get_the_ID(), 'features', '<li>', '</li><li>', '</li>'); echo '</ul><!-- .tagged-features -->'; if (get_post_meta($post->ID, '_listing_home_sum', true) != '' || get_post_meta($post->ID, '_listing_kitchen_sum', true) != '' || get_post_meta($post->ID, '_listing_living_room', true) != '' || get_post_meta($post->ID, '_listing_master_suite', true) != '') { ?> <div class="additional-features"> <h4>Additional Features</h4> <h6 class="label"><?php _e("Home Summary", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_home_sum', true)); ?> </p> <h6 class="label"><?php _e("Kitchen Summary", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_kitchen_sum', true)); ?> </p> <h6 class="label"><?php _e("Living Room", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_living_room', true)); ?> </p> <h6 class="label"><?php _e("Master Suite", 'wp_listings'); ?> </h6> <p class="value"><?php echo do_shortcode(get_post_meta($post->ID, '_listing_master_suite', true)); ?> </p> </div><!-- .additional-features --> <?php } ?> </div><!-- #listing-details --> <?php if (get_post_meta($post->ID, '_listing_gallery', true) != '') { ?> <div id="listing-gallery"> <?php echo do_shortcode(get_post_meta($post->ID, '_listing_gallery', true)); ?> </div><!-- #listing-gallery --> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_video', true) != '') { ?> <div id="listing-video"> <div class="iframe-wrap"> <?php echo get_post_meta($post->ID, '_listing_video', true); ?> </div> </div><!-- #listing-video --> <?php } ?> <?php if (get_post_meta($post->ID, '_listing_school_neighborhood', true) != '') { ?> <div id="listing-school-neighborhood"> <p> <?php echo do_shortcode(get_post_meta($post->ID, '_listing_school_neighborhood', true)); ?> </p> </div><!-- #listing-school-neighborhood --> <?php } ?> </div><!-- #listing-tabs.listing-data --> <?php if (get_post_meta($post->ID, '_listing_map', true) != '') { echo '<div id="listing-map"><h3>Location Map</h3>'; echo do_shortcode(get_post_meta($post->ID, '_listing_map', true)); echo '</div><!-- .listing-map -->'; } ?> <?php if (function_exists('_p2p_init') && function_exists('agent_profiles_init')) { echo '<div id="listing-agent"> <div class="connected-agents">'; aeprofiles_connected_agents_markup(); echo '</div></div><!-- .listing-agent -->'; } ?> <div id="listing-contact" <?php if (!function_exists('aeprofiles_connected_agents_markup')) { echo 'style="width: 100%;"'; } ?> > <h4>Listing Inquiry</h4> <?php if (get_post_meta($post->ID, '_listing_contact_form', true) != '') { echo do_shortcode(get_post_meta($post->ID, '_listing_contact_form', true)); } else { $nameError = ''; $emailError = ''; if (isset($_POST['submitted'])) { $url = get_permalink(); $listing = get_the_title(); if (trim($_POST['contactName']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } if (trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else { if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\\.[a-z]{2,4}\$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } } $phone = trim($_POST['phone']); if (function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } if (!isset($hasError)) { $emailTo = get_the_author_meta('user_email', $post->post_author); if (!isset($emailTo) || $emailTo == '') { $emailTo = get_option('admin_email'); } $subject = 'Listing Inquiry from ' . $name; $body = "Name: {$name} \n\nEmail: {$email} \n\nPhone: {$phone} \n\nListing: {$listing} \n\nURL: {$url} \n\nComments: {$comments}"; $headers = 'From: ' . $name . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php if (isset($emailSent) && $emailSent == true) { ?> <div class="thanks"> <a name="redirectTo"></a> <p>Thanks, your email was sent! We'll be in touch shortly.</p> </div> <?php } else { ?> <?php if (isset($hasError)) { ?> <a name="redirectTo"></a> <label class="error" name="redirectTo">Sorry, an error occured. Please try again.<label> <?php } ?> <form action="<?php the_permalink(); ?> #redirectTo" id="inquiry-form" method="post"> <ul class="inquiry-form"> <li class="contactName"> <label for="contactName">Name: <span class="required">*</span></label> <input type="text" name="contactName" id="contactName" value="<?php if (isset($_POST['contactName'])) { echo $_POST['contactName']; } ?> " class="required requiredField" /> <?php if ($nameError != '') { ?> <label class="error"><?php echo $nameError; ?> </label> <?php } ?> </li> <li class="contactEmail"> <label for="email">Email: <span class="required">*</span></label> <input type="text" name="email" id="email" value="<?php if (isset($_POST['email'])) { echo $_POST['email']; } ?> " class="required requiredField email" /> <?php if ($emailError != '') { ?> <label class="error"><?php echo $emailError; ?> </label> <?php } ?> </li> <li class="contactPhone"> <label for="phone">Phone:</label> <input type="text" name="phone" id="phone" value="<?php if (isset($_POST['phone'])) { echo $_POST['phone']; } ?> " /> </li> <li class="contactComments"><label for="commentsText">Message:</label> <textarea name="comments" id="commentsText" rows="6" cols="20"><?php if (isset($_POST['comments'])) { if (function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?> </textarea> </li> <li> <input id="submit" type="submit" value="Send Inquiry"></input> </li> </ul> <input type="hidden" name="submitted" id="submitted" value="true" /> </form> <?php } } ?> </div><!-- .listing-contact --> </div><!-- .entry-content --> <?php }