Check time.ly address for commas and only use first part.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 29 Jul 2016 12:11:22 +0000 (08:11 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 29 Jul 2016 12:11:22 +0000 (08:11 -0400)
If the address string for time.ly has commas then strip the rest out to
use for the street.

index.php
models/admin/management/events.php

index c72ae2c..45b890b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Members Database Events
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.2.22
+ * Version: 1.2.23
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -20,7 +20,7 @@
  * @package glmMembersDatabaseEventsAddOn
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.2.22
+ * @version 1.2.23
  */
 
 /*
@@ -38,7 +38,7 @@
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.22');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.23');
 define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.18');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index 255ae0e..976b8bd 100644 (file)
@@ -1129,7 +1129,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
     }
     public function importFromTimely() {
         $limit = 25;
-        $debug = false;
+        $debug = true;
         if ( isset( $_REQUEST['start'] ) ) {
             $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT );
         } else {
@@ -1166,7 +1166,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
            AND post_status = 'publish'";
         //$sql .= " AND ID IN ( SELECT post_id FROM " . $this->wpdb->prefix . "ai1ec_events
         //WHERE end >= " . time() . " )";
-        //$sql .= " AND ID IN ( 1647 )";
+        $sql .= " AND ID IN ( 3785 )";
         $sql .= " LIMIT $limit OFFSET $start";
         $results = $this->wpdb->get_results( $sql, ARRAY_A );
 
@@ -1698,7 +1698,12 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement
                         $location_format[] = '%s';
                     }
                     if ($event_data['address']) {
-                        $location_data['address'] = $event_data['address'];
+                        // test the address to see if there's commas
+                        if ( strpos( $event_data['address'], ',' ) === false) {
+                            $location_data['address'] = $event_data['address'];
+                        } else {
+                            $location_data['address'] = substr( $event_data['address'], 0, strpos( $event_data['address'], ',' ) );
+                        }
                         $location_format[] = '%s';
                     }
                     if ($event_data['city']) {