Skip to content

Commit

Permalink
Merge pull request #72 from SimplyRETS/wip-listhub-test-events-option
Browse files Browse the repository at this point in the history
Add admin option to enable/disable ListHub test events
  • Loading branch information
CodyReichert authored Apr 11, 2018
2 parents 590a63b + a68368d commit cb8dfc3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.4.2
* UPDATE: Add admin option to enable/disable ListHub analytics test events.

## 2.4.1
* FIX: Update responsive media queries for bigger mobile device screen sizes.

Expand Down
5 changes: 4 additions & 1 deletion 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.9.4
Stable tag: 2.4.1
Stable tag: 2.4.2
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.4.2 =
* UPDATE: Add admin option to enable/disable ListHub analytics test events.

= 2.4.1 =
* FIX: Update responsive media queries for bigger mobile device screen sizes.

Expand Down
12 changes: 12 additions & 0 deletions simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function register_admin_settings() {
register_setting('sr_admin_settings', 'sr_additional_rooms');
register_setting('sr_admin_settings', 'sr_listhub_analytics');
register_setting('sr_admin_settings', 'sr_listhub_analytics_id');
register_setting('sr_admin_settings', 'sr_listhub_analytics_test_events');
register_setting('sr_admin_settings', 'sr_search_map_position');
register_setting('sr_admin_settings', 'sr_permalink_structure');
register_setting('sr_admin_settings', 'sr_google_api_key');
Expand Down Expand Up @@ -484,6 +485,17 @@ function sr_admin_page() {
</label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_listhub_analytics_test_events" name="sr_listhub_analytics_test_events" value="1" '
. checked(1, get_option('sr_listhub_analytics_test_events'), false) . '/>'
?>
Send test events to ListHub <i>(disable for live events)</i>
</label>
</td>
</tr>
<tr>
<td>
<strong>Metrics Provider ID</strong><br><i> (provided by Listhub)</i>
Expand Down
18 changes: 11 additions & 7 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.4.1 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.4.2 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.4.1 Wordpress/{$wp_version} PHP/{$php_version}";
$ua_string = "SimplyRETSWP/2.4.2 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 @@ -873,15 +873,19 @@ public static function srResidentialDetailsGenerator( $listing ) {
* Check for ListHub Analytics
*/
if( get_option( 'sr_listhub_analytics' ) ) {

$lh_analytics = SimplyRetsApiHelper::srListhubAnalytics();
if( get_option( 'sr_listhub_analytics_id' ) ) {
$metrics_id = get_option( 'sr_listhub_analytics_id' );
$lh_id = get_option('sr_listhub_analytics_id', false);
$lh_test = get_option('sr_listhub_analytics_test_events') ? 1 : false;

if($lh_id) {
$lh_send_details = SimplyRetsApiHelper::srListhubSendDetails(
$metrics_id
, true
$lh_id
, $lh_test
, $listing_mlsid
, $postal_code
);

$lh_analytics .= $lh_send_details;
}
} else {
Expand Down Expand Up @@ -1731,7 +1735,7 @@ public static function srListhubAnalytics() {

public static function srListhubSendDetails( $m, $t, $mlsid, $zip=NULL ) {
$metrics_id = $m;
$test = $t;
$test = json_encode($t);
$mlsid = $mlsid;
$zipcode = $zip;

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.4.1
Version: 2.4.2
License: GNU General Public License v3 or later
Copyright (c) SimplyRETS 2014 - 2015
Expand Down

0 comments on commit cb8dfc3

Please sign in to comment.