Skip to content

Commit

Permalink
Merge pull request #42 from SimplyRETS/wip-no-empty-params
Browse files Browse the repository at this point in the history
Don't send empty 'status' and 'type' parameters to API
  • Loading branch information
CodyReichert committed Jan 4, 2017
2 parents 6d3057f + 2c5f0aa commit 526df78
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.4
* BUGFIX: Don't send empty 'status' and 'type' parameters to the API.
* DOCUMENTATION: Update documentation for 'area' parameter.

## 2.2.3
* DOCUMENTATION: Remove unsupported 'lotsize' parameter from documentation.

Expand Down
10 changes: 5 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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
Stable tag: 2.2.3
Stable tag: 2.2.4
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 2.2.4 =
* BUGFIX: Don't send empty 'status' and 'type' parameters to the API.
* DOCUMENTATION: Update documentation for 'area' parameter.

= 2.2.3 =
* DOCUMENTATION: Remove unsupported 'lotsize' parameter from documentation.

Expand Down Expand Up @@ -502,10 +506,6 @@ Refines listings to a specific agent by taking an agent's MLS ID.
Refines listings to a specific brokerage by taking a brokerage's MLS ID.
`[sr_listings brokers="KWREALTY1"]`

* **area**
Refines listings by a certain area size in Sq Ft.
`[sr_listings area="1500"]`

* **cities**
Refines listings to a given set of cities. (Separate multiple with a semi-colon).
`[sr_listings cities="Houston; Austin; Dallas"]`
Expand Down
2 changes: 1 addition & 1 deletion simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ function sr_admin_page() {
<div>
<span>
<i>Note - to use the SimplyRETS demo data, you can use these API credentials: </i>
<strong>API Username: </strong><span>simplyrets</span>
<strong>API Key: </strong><span>simplyrets</span>
<strong>API Secret: </strong><span>simplyrets</span>
</span>
<div>
<?php submit_button(); ?>
Expand Down
10 changes: 5 additions & 5 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.3 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.2.4 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.3 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.2.4 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 @@ -1511,7 +1511,7 @@ public static function srContactFormMarkup($listing) {
$markup .= '<p>';
$markup .= '<input type="hidden" name="sr-cf-listing" value="' . $listing . '" />';
$markup .= 'Your Name (required) <br/>';
$markup .= '<input type="text" name="sr-cf-name" pattern="[a-zA-Z0-9 ]+" value="'
$markup .= '<input type="text" name="sr-cf-name" value="'
. ( isset( $_POST["sr-cf-name"] ) ? esc_attr( $_POST["sr-cf-name"] ) : '' ) . '" size="40" />';
$markup .= '</p>';
$markup .= '<p>';
Expand All @@ -1521,7 +1521,7 @@ public static function srContactFormMarkup($listing) {
$markup .= '</p>';
$markup .= '<p>';
$markup .= 'Subject (required) <br/>';
$markup .= '<input type="text" name="sr-cf-subject" pattern="[a-zA-Z ]+" value="'
$markup .= '<input type="text" name="sr-cf-subject" value="'
. ( isset( $_POST["sr-cf-subject"] ) ? esc_attr( $_POST["sr-cf-subject"] ) : '' ) . '" size="40" />';
$markup .= '</p>';
$markup .= '<p>';
Expand Down Expand Up @@ -1557,7 +1557,7 @@ public static function srContactFormDeliver() {

// If email has been process for sending, display a success message
if ( wp_mail( $to, $subject, $message, $headers ) ) {
echo '<div></div>';
echo '<div id="sr-contact-form-success">Your message was delivered successfully.</div>';
} else {
echo 'An unexpected error occurred';
}
Expand Down
32 changes: 22 additions & 10 deletions simply-rets-post-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,16 @@ public static function srPostDefaultContent( $content ) {


/**
* Check if there is multiple 'types' being searched.
* HACK: This is a bit of hack because sometimes the parameters
* are in an array() and sometimes they are in a string that needs
* to be made into an array. The others aren't like that,
* so we should fix this one.
* Format the 'type' parameter.
* Note that the 'type' might come in as an Array or a
* String. For strings, we split on ";" to support
* multiple property types only if the string is not
* empty. Arrays are concated into multiple type=
* parameters.
*/

/** Multiple Types */
$p_types = isset($_GET['sr_ptype']) ? $_GET['sr_ptype'] : '';
$ptypes_string = '';
if(!is_array($p_types)) {
if(!is_array($p_types) && !empty($p_types)) {
if(strpos($p_types, ";") !== FALSE) {
$p_types = explode(';', $p_types);
} else {
Expand All @@ -581,10 +580,22 @@ public static function srPostDefaultContent( $content ) {
}


/** Multiple Statuses */
/**
* Format the 'status' parameter.
* Note that the 'status' might come in as an Array or a
* String. For strings, we split on ";" to support
* multiple statuses only if the string is not empty.
* Arrays are concated into multiple status= parameters.
*
* NOTE: it is important to not send an empty status
* parameter, for example "status=" to the API, as it will
* interpret it as Active, whereas _no_ status parameter
* is Active and Pending.
*/
$statuses = isset($_GET['sr_status']) ? $_GET['sr_status'] : $status;
$statuses_string = '';
if(!is_array($statuses)) {

if(!is_array($statuses) && !empty($statuses)) {
if(strpos($statuses, ";") !== FALSE) {
$statuses = explode(';', $statuses);
} else {
Expand All @@ -598,6 +609,7 @@ public static function srPostDefaultContent( $content ) {
}
}


/**
* The loops below check if the short-code has multiple
* values for any query parameter. Eg, multiple cities.
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.3
Version: 2.2.4
License: GNU General Public License v3 or later
Copyright (c) SimplyRETS 2014 - 2015
Expand Down

0 comments on commit 526df78

Please sign in to comment.