Skip to content

Commit

Permalink
Merge pull request #45 from SimplyRETS/wip-mls-status-option
Browse files Browse the repository at this point in the history
Add admin option to show MLS status text
  • Loading branch information
CodyReichert authored Feb 6, 2017
2 parents b710804 + 1b20786 commit 0e8abec
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.2.6
* FEATURE: Add admin option to use "statusText" API field in place of the standardized status.

## 2.2.5
* FEATURE: Add contact form info (name, email, listing) to the end of the email message body.

Expand Down
12 changes: 7 additions & 5 deletions assets/js/simply-rets-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ var buildUglyLink = function(mlsId, address, root) {
}


var genMarkerPopup = function(listing, linkStyle, siteRoot, idxImg, officeOnThumbnails) {
var genMarkerPopup = function(listing, linkStyle, siteRoot, idxImg, officeOnThumbnails, statusText) {

var stat = listing.mls.status || "Active";
var stat = statusText ? listing.mls.statusText : listing.mls.status;
var baths = listing.property.bathsFull || "n/a";
var beds = listing.property.bedrooms || "n/a";
var style = listing.property.style || "Res" ;
Expand Down Expand Up @@ -155,7 +155,7 @@ var genMarkerPopup = function(listing, linkStyle, siteRoot, idxImg, officeOnThum
}


var makeMapMarkers = function(map, listings, linkStyle, siteRoot, idxImg, officeOnThumbnails) {
var makeMapMarkers = function(map, listings, linkStyle, siteRoot, idxImg, officeOnThumbnails, statusText) {
// if(!listings || listings.length < 1) return [];

var markers = [];
Expand All @@ -170,7 +170,7 @@ var makeMapMarkers = function(map, listings, linkStyle, siteRoot, idxImg, office

var bound = new google.maps.LatLng(listing.geo.lat, listing.geo.lng);

var popup = genMarkerPopup(listing, linkStyle, siteRoot, idxImg, officeOnThumbnails);
var popup = genMarkerPopup(listing, linkStyle, siteRoot, idxImg, officeOnThumbnails, statusText);

var window = new google.maps.InfoWindow({
content: popup
Expand Down Expand Up @@ -506,6 +506,7 @@ Map.prototype.handleRequest = function(that, data) {
var idxImg = document.getElementById('sr-map-search').dataset.idxImg;
var officeOnThumbnails = document.getElementById('sr-map-search').dataset.officeOnThumbnails;
var linkStyle = data.permalink_structure === "" ? "default" : "pretty";
var statusText = data.show_mls_status_text;

that.siteRoot = data.site_root
that.linkStyle = linkStyle;
Expand All @@ -518,7 +519,8 @@ Map.prototype.handleRequest = function(that, data) {
, that.linkStyle
, that.siteRoot
, idxImg
, officeOnThumbnails);
, officeOnThumbnails
, statusText );

that.bounds = markers.bounds;
that.markers = markers.markers;
Expand Down
85 changes: 71 additions & 14 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Author: SimplyRETS
Contributors: SimplyRETS
Tags: rets, idx, real estate listings, real estate, listings, rets listings, simply rets, realtor, rets feed, idx feed
Requires at least: 3.0.1
Tested up to: 4.7.1
Stable tag: 2.2.5
Tested up to: 4.7.2
Stable tag: 2.2.6
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -235,6 +235,9 @@ listing sidebar widget.

== Changelog ==

= 2.2.6 =
* FEATURE: Add admin option to use "statusText" API field in place of the standardized status.

= 2.2.5 =
* FEATURE: Add contact form info (name, email, listing) to the end of the email message body.

Expand Down Expand Up @@ -593,21 +596,75 @@ sidebar and footer. The currently available widgets include:
This sections will discuss some of the basic configuration options
available to admin's through the plugin:

* **Permalinks**
SimplyRETS has support for 'pretty' and 'ugly' permalinks. It will
choose the best one based on your current configuration and there
are a couple of options to fine-tune it.
= Account credentials =

The account credentials section in the admin settings is where you'll
enter your API Credentials for your SimplyRETS app. If you don't yet
have a SimplyRETS app, the default *demo* credentials will be
available.

= Single Listing Page Settings =

These settings allow you to control various parts of the listing
details pages, including the contact form and some of the fields that
are shown.

**Contact form lead capture**

When this is enabled, a lead capture contact form will be shown at the
bottom of listing details pages. In the *Send lead capture form
submissions to* input, you can enter the email address where you'd
like to receive lead emails.

*Note: The WordPress admin email is used if no email is provided*

**Show/Hide fields**

Show and/or hide various parts of the listing details page:

* Hide 'Listing meta information' fields from property details?
This option hides `listDate`, `modificationTimestamp`, `taxYear`,
and `taxAmmount` from listing details pages.

* Do not show Agent/Office phone number and email address
If checked, the listing office and agent's contact information will
not be shown. Note that, in most cases, the name will still be
shown.

* Hide 'Listing Remarks' (description) field from property details?
If checked, the listing description will not be dispayed.

* Show additional room details?
If available, extra information about the listing's rooms will be
shown when this is enabled.

* Show MLS status text if available (hide standardized status)?
If a `statusText` is available for the listing, show that instead of
the standardized status. Read more about `statusText`
[here](https://docs.simplyrets.com/api/index.html#!/default/get_properties)

= Image gallery settings =

There are two types of image galleries available for listing details
pages: *fancy* and *classic*. Here, you can choose which one you'd
like to use.

**Permalinks**

SimplyRETS has support for 'pretty' and 'ugly' permalinks. It will
choose the best one based on your current configuration and there
are a couple of options to fine-tune it.

- If your WordPress site uses 'default' (ugly) permalinks, the
plugin is forced to use those as well.
- If your WordPress site uses 'default' (ugly) permalinks, the
plugin is forced to use those as well.

- If your WordPress site is using 'pretty' permalinks, you can
choose between 'pretty' and 'extra pretty' SimplyRETS links in the
"Permalnks" section of the admin panel. Here are some basic
examples:
- If your WordPress site is using 'pretty' permalinks, you can
choose between 'pretty' and 'extra pretty' SimplyRETS links in the
"Permalnks" section of the admin panel. Here are some basic
examples:

*Pretty*: http://yoursite.com/listings/{id}/{streetAddress}
*Extra Pretty*: http://yoursite.com/listings/{city}/{state}/{postalCode}/{streetAddress}/{id}
*Pretty*: http://yoursite.com/listings/{id}/{streetAddress}
*Extra Pretty*: http://yoursite.com/listings/{city}/{state}/{postalCode}/{streetAddress}/{id}


== MLS Compliance Settings ==
Expand Down
13 changes: 13 additions & 0 deletions simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function register_admin_settings() {
register_setting('sr_admin_settings', 'sr_office_on_thumbnails');
register_setting('sr_admin_settings', 'sr_thumbnail_idx_image');
register_setting('sr_admin_settings', 'sr_custom_disclaimer');
register_setting('sr_admin_settings', 'sr_show_mls_status_text');
}

public static function adminMessages () {
Expand Down Expand Up @@ -238,6 +239,18 @@ function sr_admin_page() {
</td>
</tr>

<tr>
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_show_mls_status_text" name="sr_show_mls_status_text" value="1" '
. checked(1, get_option('sr_show_mls_status_text'), false) . '/>'
?>
Show MLS status text if available (in place of standardized status)?
</label>
</td>
</tr>

</tbody>
</table>
<h3>Image Gallery Settings</h3>
Expand Down
30 changes: 22 additions & 8 deletions simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function srApiOptionsRequest( $url ) {
$php_version = phpversion();
$site_url = get_site_url();

$ua_string = "SimplyRETSWP/2.2.5 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.2.6 Wordpress/{$wp_version} PHP/{$php_version}";
$accept_header = "Accept: application/json; q=0.2, application/vnd.simplyrets-v0.1+json";

if( is_callable( 'curl_init' ) ) {
Expand Down Expand Up @@ -209,7 +209,7 @@ public static function srApiRequest( $url ) {
$wp_version = get_bloginfo('version');
$php_version = phpversion();

$ua_string = "SimplyRETSWP/2.2.5 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.2.6 Wordpress/{$wp_version} PHP/{$php_version}";
$accept_header = "Accept: application/json; q=0.2, application/vnd.simplyrets-v0.1+json";

if( is_callable( 'curl_init' ) ) {
Expand Down Expand Up @@ -521,6 +521,15 @@ public static function srResidentialDetailsGenerator( $listing ) {
// internal unique id
$listing_uid = $listing->mlsId;

/**
* Get the listing status to show. Note that if the
* sr_show_mls_status_text admin option is set to true, we
* will show the listing's "statusText" and not the normalized
* status.
*/
$listing_mls_status = SrListing::listingStatus($listing);
$mls_status = SimplyRetsApiHelper::srDetailsTable($listing_mls_status, "MLS Status");

// price
$listing_price = $listing->listPrice;
$listing_price_USD = '$' . number_format( $listing_price );
Expand Down Expand Up @@ -585,9 +594,6 @@ public static function srResidentialDetailsGenerator( $listing ) {
// unit
$listing_unit = $listing->address->unit;
$unit = SimplyRetsApiHelper::srDetailsTable($listing_unit, "Unit");
// mls information
$listing_mls_status = $listing->mls->status;
$mls_status = SimplyRetsApiHelper::srDetailsTable($listing_mls_status, "MLS Status");
// int/ext features
$listing_interiorFeatures = $listing->property->interiorFeatures;
$interiorFeatures = SimplyRetsApiHelper::srDetailsTable($listing_interiorFeatures, "Features");
Expand Down Expand Up @@ -1211,7 +1217,6 @@ public static function srResidentialResultsGenerator( $response, $settings ) {
$listing_agent_name = $listing->agent->firstName . ' ' . $listing->agent->lastName;
$lng = $listing->geo->lng;
$lat = $listing->geo->lat;
$mls_status = $listing->mls->status;
$propType = $listing->property->type;
$bedrooms = $listing->property->bedrooms;
$bathsFull = $listing->property->bathsFull;
Expand All @@ -1223,6 +1228,11 @@ public static function srResidentialResultsGenerator( $response, $settings ) {
$style = $listing->property->style;
$yearBuilt = $listing->property->yearBuilt;

/**
* Listing status to show. This may return a statusText.
*/
$mls_status = SrListing::listingStatus($listing);

$addrFull = $address . ', ' . $city . ' ' . $zip;
$listing_USD = $listing_price == "" ? "" : '$' . number_format( $listing_price );

Expand Down Expand Up @@ -1435,17 +1445,21 @@ public static function srWidgetListingGenerator( $response, $settings ) {

foreach ( $response as $listing ) {
$listing_uid = $listing->mlsId;
$listing_remarks = $listing->remarks;

// widget details
$bedrooms = $listing->property->bedrooms;
if( $bedrooms == null || $bedrooms == "" ) {
$bedrooms = 0;
}

$bathsFull = $listing->property->bathsFull;
if( $bathsFull == null || $bathsFull == "" ) {
$bathsFull = 0;
}
$mls_status = $listing->mls->status;
$listing_remarks = $listing->remarks;

$mls_status = SrListing::listingStatus($listing);

$listing_price = $listing->listPrice;
$listing_USD = '$' . number_format( $listing_price );

Expand Down
2 changes: 2 additions & 0 deletions simply-rets-maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static function update_int_map_data() {
&& $_POST['action'] === "update_int_map_data") {

$permalink_struct = get_option('permalink_structure');
$showStatusText = get_option('sr_show_mls_status_text', false);
$site_root = get_site_url();

header("Content-Type: application/json");
Expand All @@ -147,6 +148,7 @@ public static function update_int_map_data() {
"markup" => $con,
"post" => $_POST,
"permalink_structure" => $permalink_struct,
"show_mls_status_text" => $showStatusText,
"site_root" => $site_root
);

Expand Down
13 changes: 13 additions & 0 deletions simply-rets-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,19 @@ public static function mkDisclaimerText($lastUpdate) {
}


class SrListing {

/**
* Return a 'display-ready' status for a listing. Checks the
* sr_show_mls_status_text option and returns either the
* statusText or status for the listing.
*/
public static function listingStatus($listing) {
$useStatusText = get_option('sr_show_mls_status_text', false);
return $useStatusText ? $listing->mls->statusText : $listing->mls->status;
}
}


class SrMessages {

Expand Down
2 changes: 1 addition & 1 deletion simply-rets.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: https://simplyrets.com
Description: Show your Real Estate listings on your Wordpress site. SimplyRETS provides a very simple set up and full control over your listings.
Author: SimplyRETS
Version: 2.2.5
Version: 2.2.6
License: GNU General Public License v3 or later
Copyright (c) SimplyRETS 2014 - 2015
Expand Down

0 comments on commit 0e8abec

Please sign in to comment.