Skip to content

Commit

Permalink
3.44.0.1
Browse files Browse the repository at this point in the history
* Fixed new Keap / Infusionsoft integration not loading more than 1000 each of tags or tag categories
* Fixed Keap / Infusionsoft integration not importing all contacts if no tag was specified for the import
  • Loading branch information
verygoodplugins committed Aug 6, 2024
1 parent 1a45c89 commit 9f561cf
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 24 deletions.
82 changes: 61 additions & 21 deletions includes/crms/infusionsoft/class-infusionsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ class WPF_Infusionsoft_iSDK {
/**
* Contains API params
*/

public $params;
public $params;

/**
* Allows for direct access to the API, bypassing WP Fusion
*/

public $app;
public $app;


/**
Expand Down Expand Up @@ -454,35 +452,71 @@ public function sync() {
*/
public function sync_tags() {

$response = wp_safe_remote_get( $this->url . 'tags/', $this->get_params() );
// Get the categories first.

if ( is_wp_error( $response ) ) {
return $response;
}
$categories = array();

$category_response = wp_safe_remote_get( $this->url . 'tags/categories/', $this->get_params() );
$url = $this->url . 'tags/categories/?page_size=1000';

if ( is_wp_error( $category_response ) ) {
return $category_response;
while ( $url ) {

$response = wp_safe_remote_get( $url, $this->get_params() );

if ( is_wp_error( $response ) ) {
return $response;
}

$response = json_decode( wp_remote_retrieve_body( $response ), true );

$categories = array_merge( $categories, $response['tag_categories'] );

if ( empty( $response['next_page_token'] ) ) {
break;
}

$url = $response['next_page_token'];
}

$response = json_decode( wp_remote_retrieve_body( $response ), true );
$category_response = json_decode( wp_remote_retrieve_body( $category_response ), true );
// Then get the tags.

$tags = array();

$url = $this->url . 'tags/?page_size=1000';

while ( $url ) {

$response = wp_safe_remote_get( $url, $this->get_params() );

if ( is_wp_error( $response ) ) {
return $response;
}

$response = json_decode( wp_remote_retrieve_body( $response ), true );

$tags = array_merge( $tags, $response['tags'] );

if ( empty( $response['next_page_token'] ) ) {
break;
}

$url = $response['next_page_token'];
}

$available_tags = array();

foreach ( $response['tags'] as $tag ) {
foreach ( $tags as $tag ) {
$available_tags[ $tag['id'] ]['label'] = $tag['name'];

$category_name = 'No Category';

$category_index = false;
if ( isset( $tag['category']['id'] ) && isset( $category_response['tag_categories'] ) ) {
$category_index = array_search( $tag['category']['id'], array_column( $category_response['tag_categories'], 'id' ) );

if ( isset( $tag['category']['id'] ) ) {
$category_index = array_search( $tag['category']['id'], array_column( $categories, 'id' ) );
}

if ( $category_index !== false ) {
$category_name = $category_response['tag_categories'][ $category_index ]['name'];
if ( $category_index ) {
$category_name = $categories[ $category_index ]['name'];
}

$available_tags[ $tag['id'] ]['category'] = $category_name;
Expand Down Expand Up @@ -1167,15 +1201,21 @@ function ( $field ) use ( $available_fields ) {
* @since 1.0.0
* @since 3.44.0 Updated to use REST API.
*
* @param string $tag The tag name.
* @param string $tag|bool The tag name or false to load all contacts.
* @return array|WP_Error The contact IDs or error.
*/
public function load_contacts( $tag = false ) {

$contact_ids = array();
$proceed = true;

$request = $this->url . 'tags/' . $tag . '/contacts/';
while ( $proceed == true ) {
if ( $tag ) {
$request = $this->url . 'tags/' . $tag . '/contacts/';
} else {
$request = $this->url . 'contacts/';
}

while ( $proceed ) {
$response = wp_safe_remote_get( $request, $this->get_params() );

if ( is_wp_error( $response ) ) {
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: crm, marketing automation, sync, integration, membership
Requires at least: 4.6
Requires PHP: 5.6
Tested up to: 6.6.2
Stable tag: 3.44.0
Stable tag: 3.44.0.1

WP Fusion Lite synchronizes your WordPress users with contact records in your CRM or marketing automation system.

Expand Down Expand Up @@ -203,6 +203,10 @@ Of course, see our [Frequently Asked Questions](https://wpfusion.com/documentati

== Changelog ==

= 3.44.0.1 - 8/6/2024 =
* Fixed new Keap / Infusionsoft integration not loading more than 1000 each of tags or tag categories
* Fixed Keap / Infusionsoft integration not importing all contacts if no tag was specified for the import

= 3.44.0 - 8/5/2024 =
* Big update: WP Fusion has been updated to use the Infusionsoft REST API, and [Service Account Keys](https://developer.infusionsoft.com/pat-and-sak/) for authentication. You will need to update your API credentials to ensure uninterrupted service
* Improved - wpf_get_iso8601_date() will now more forcefully use GMT for the time zone instead of the local time
Expand Down
4 changes: 2 additions & 2 deletions wp-fusion-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: WP Fusion Lite
* Description: WP Fusion Lite synchronizes your WordPress users with your CRM or marketing automation system.
* Plugin URI: https://wpfusion.com/
* Version: 3.44.0
* Version: 3.44.0.1
* Author: Very Good Plugins
* Author URI: https://verygoodplugins.com/
* Text Domain: wp-fusion-lite
Expand All @@ -28,7 +28,7 @@
* **********************************************************************
*/

define( 'WP_FUSION_VERSION', '3.44.0' );
define( 'WP_FUSION_VERSION', '3.44.0.1' );

// deny direct access.
if ( ! function_exists( 'add_action' ) ) {
Expand Down

0 comments on commit 9f561cf

Please sign in to comment.