From c0e0c3501a0c77c0f96eb51ab102287ec313c55d Mon Sep 17 00:00:00 2001 From: Luis Godinho Date: Mon, 31 Mar 2014 19:23:51 +0100 Subject: [PATCH 1/2] Logging Enable log_debug using Gravity Forms Logging Add-on --- infusionsoft.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/infusionsoft.php b/infusionsoft.php index b760a0e..319f5d4 100644 --- a/infusionsoft.php +++ b/infusionsoft.php @@ -48,6 +48,8 @@ class GFInfusionsoft { public static function init(){ global $pagenow; + self::log_debug('init version: ' . self::$version ); + load_plugin_textdomain('gravity-forms-infusionsoft', FALSE, '/gravity-forms-infusionsoft/languages' ); if($pagenow === 'plugins.php') { @@ -73,6 +75,9 @@ public static function init(){ if(self::has_access("gravityforms_infusionsoft")){ RGForms::add_settings_page("Infusionsoft", array("GFInfusionsoft", "settings_page"), self::get_base_url() . "/images/infusionsoft_wordpress_icon_32.png"); } + + // Enable debug with Gravity Forms Logging Add-on + add_filter( 'gform_logging_supported', array( 'GFInfusionsoft', 'add_debug_settings' ) ); } //integrating with Members plugin @@ -1521,10 +1526,15 @@ public static function get_mapped_field_checkbox($variable_name, $selected_field } public static function export($entry, $form){ + + self::log_debug( 'init export. Entry ID: ' . $entry['id'] ); + //Login to Infusionsoft $api = self::get_api(); - if(!empty($api->lastError)) + if(!empty($api->lastError)) { + self::log_debug( 'Infusionsoft API Error: ' . print_r( $api->lastError, true ) ); return; + } //loading data class require_once(self::get_base_path() . "/data.php"); @@ -1539,9 +1549,13 @@ public static function export($entry, $form){ public static function export_feed($entry, $form, $feed, $api){ + self::log_debug( '[Entry ID: '. $entry['id'] . '] Init Export Feed: ' . print_r( $feed, true ) ); + $email_field_id = $feed["meta"]["field_map"]["Email"]; $email = $entry[$email_field_id]; + self::log_debug( '[Entry ID: '. $entry['id'] . '] Email: ' . print_r( $email, true ) ); + $merge_vars = array(); foreach($feed["meta"]["field_map"] as $var_tag => $field_id){ @@ -1571,18 +1585,24 @@ public static function export_feed($entry, $form, $feed, $api){ } } + self::log_debug( '[Entry ID: '. $entry['id'] . '] Infusionsoft Merge Data: ' . print_r( $merge_vars, true ) ); + $valid = self::test_api(); if($valid) { $contact_id = self::add_contact($email, $merge_vars); + self::log_debug( '[Entry ID: '. $entry['id'] . '] Contact ID: ' . print_r( $contact_id, true ) ); + if($contact_id) { $tags_added = self::add_tags_to_contact($contact_id, $merge_vars, $feed, $entry, $form); + self::log_debug( '[Entry ID: '. $entry['id'] . '] Adding Tags: ' . print_r( $tags_added, true ) ); } // Only set them as marketable if they opt-in // http://help.infusionsoft.com/developers/services-methods/email/optIn if(self::is_optin($form, $feed)) { $opt_in = self::opt_in($email, $entry); + self::log_debug( '[Entry ID: '. $entry['id'] . '] Opt In: ' . print_r( $opt_in, true ) ); } if(self::is_debug()) { @@ -1597,11 +1617,14 @@ public static function export_feed($entry, $form, $feed, $api){ 'Adding Tags' => $tags_added, )); } - + self::log_debug( '[Entry ID: '. $entry['id'] . '] Form Entry Data: ' . print_r( $entry, true ) ); + self::log_debug( '[Entry ID: '. $entry['id'] . '] Posted Data ($_POST): ' . print_r( $_POST, true ) ); self::add_note($entry, $contact_id); } elseif(current_user_can('administrator')) { echo '
'.wpautop(sprintf(__("The form didn't create a contact because the Infusionsoft Gravity Forms Add-on plugin isn't properly configured. %sCheck the configuration%s and try again.", 'gravity-forms-infusionsoft'), '', '')).'
'; + + self::log_debug( '[Entry ID: '. $entry['id'] . '] '. "API Error: The form didn't create a contact because the Infusionsoft Gravity Forms Add-on plugin isn't properly configured. " ); } } @@ -1887,5 +1910,26 @@ static protected function get_base_path(){ return WP_PLUGIN_DIR . "/" . $folder; } + /** + * Enables debug with Gravity Forms logging add-on + * @param array $supported_plugins List of plugins + */ + public static function add_debug_settings( $supported_plugins ) { + $supported_plugins['infusionsoft'] = 'Gravity Forms Infusionsoft Add-on'; + return $supported_plugins; + } + + /** + * Logs messages using Gravity Forms logging add-on + * @param string $message log message + * @return void + */ + public static function log_debug( $message ){ + if ( class_exists("GFLogging") ) { + GFLogging::include_logger(); + GFLogging::log_message('infusionsoft', $message, KLogger::DEBUG); + } + } + } From 1476573b755ee1f84181abec4db935137de778c2 Mon Sep 17 00:00:00 2001 From: Luis Godinho Date: Mon, 31 Mar 2014 19:27:43 +0100 Subject: [PATCH 2/2] version bump --- infusionsoft.php | 4 ++-- readme.txt | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/infusionsoft.php b/infusionsoft.php index 319f5d4..db679e1 100644 --- a/infusionsoft.php +++ b/infusionsoft.php @@ -3,7 +3,7 @@ Plugin Name: Gravity Forms Infusionsoft Add-On Plugin URI: http://katz.co Description: Integrates Gravity Forms with Infusionsoft allowing form submissions to be automatically sent to your Infusionsoft account -Version: 1.5.7.1 +Version: 1.5.7.2 Author: Katz Web Services, Inc. Author URI: http://www.katzwebservices.com @@ -34,7 +34,7 @@ class GFInfusionsoft { private static $path = "gravity-forms-infusionsoft/infusionsoft.php"; private static $url = "http://www.gravityforms.com"; private static $slug = "gravity-forms-infusionsoft"; - private static $version = "1.5.7.1"; + private static $version = "1.5.7.2"; private static $min_gravityforms_version = "1.3.9"; private static $is_debug = NULL; private static $debug_js = false; diff --git a/readme.txt b/readme.txt index de0840c..6698ab0 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Tags: gravity forms, forms, gravity, form, crm, gravity form, infusionsoft, Infusion Soft, small business, business, marketing, e-commerce Requires at least: 3.3 Tested up to: 3.8 -Stable tag: 1.5.7.1 +Stable tag: 1.5.7.2 Contributors: katzwebdesign, katzwebservices Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zackkatz%40gmail%2ecom&item_name=Gravity%20Forms%20Infusionsoft&no_shipping=0&no_note=1&tax=0¤cy_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8 @@ -60,6 +60,9 @@ This plugin is released under a GPL license. == Changelog == += 1.5.7.2 = +* Added: Enable debug logging using Gravity Forms Logging Add-on + = 1.5.7.1 = * Fixes PHP warning related with unkonw form_id index on line 772 * Fixes "Refresh Fields & Tags" link after saving feed - avoid feed duplication @@ -153,6 +156,8 @@ This plugin is released under a GPL license. * Liftoff! == Upgrade Notice == += 1.5.7.2 = +* Added: Enable debug logging using Gravity Forms Logging Add-on = 1.5.7.1 = * Fixes PHP warning related with unkonw form_id index on line 772