Skip to content

Commit 0422f31

Browse files
author
Woo
committed
Updates to 6.0.31
1 parent 724b28a commit 0422f31

File tree

6 files changed

+89
-30
lines changed

6 files changed

+89
-30
lines changed

automatewoo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: AutomateWoo
44
* Plugin URI: https://automatewoo.com
55
* Description: Powerful marketing automation for your WooCommerce store.
6-
* Version: 6.0.30
6+
* Version: 6.0.31
77
* Author: WooCommerce
88
* Author URI: https://woocommerce.com
99
* License: GPLv3
@@ -37,7 +37,7 @@
3737
defined( 'ABSPATH' ) || exit;
3838

3939
define( 'AUTOMATEWOO_SLUG', 'automatewoo' );
40-
define( 'AUTOMATEWOO_VERSION', '6.0.30' ); // WRCS: DEFINED_VERSION.
40+
define( 'AUTOMATEWOO_VERSION', '6.0.31' ); // WRCS: DEFINED_VERSION.
4141
define( 'AUTOMATEWOO_FILE', __FILE__ );
4242
define( 'AUTOMATEWOO_PATH', __DIR__ );
4343
define( 'AUTOMATEWOO_MIN_PHP_VER', '7.4.0' );

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*** AutomateWoo Changelog ***
22

3+
2024-08-06 - version 6.0.31
4+
* Dev - Fix false positive warning in QIT.
5+
* Fix - Add Active Campaign Pagination for tags.
6+
37
2024-07-24 - version 6.0.30
48
* Dev - Upgrade to use Node.js 20 and bump npm dependencies.
59
* Fix - HTML formatting in the Workflows timing column.

includes/Actions/Send_Email_Raw.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function get_preview() {
7171
// no user should be logged in
7272
// When the user_id value is 0, it's a session for a logged-out user
7373
// see https://wordpress.org/support/topic/sessions-with-user-id-0/
74-
// phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
74+
// phpcs:ignore Generic.PHP.ForbiddenFunctions
7575
wp_set_current_user( 0 );
7676

7777
return $this->get_workflow_email_object( $current_user->get( 'user_email' ), $html )

includes/Integrations/ActiveCampaign.php

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public function is_enabled(): bool {
6363
*
6464
* @see https://developers.activecampaign.com/reference/create-a-new-contact
6565
*
66-
* @param string $email Email address for the contact
66+
* @param string $email Email address for the contact
6767
* @param string $first_name First name for the contact
68-
* @param string $last_name Last name for the contact
69-
* @param string $phone Phone number for the contact
70-
* @param string $company Company for the contact
68+
* @param string $last_name Last name for the contact
69+
* @param string $phone Phone number for the contact
70+
* @param string $company Company for the contact
7171
*
7272
* @return bool|array An array containing contact details or false if unsuccessful
7373
*/
@@ -110,9 +110,9 @@ public function sync_contact( $email, $first_name = false, $last_name = false, $
110110
*
111111
* @see https://developers.activecampaign.com/reference/create-an-account-1
112112
*
113-
* @param string $contact_id ID of the contact to sync company data for
113+
* @param string $contact_id ID of the contact to sync company data for
114114
* @param string $current_company_id ID of the company currently associated with the contact ("0" = none)
115-
* @param string $company_name Name of the company to sync
115+
* @param string $company_name Name of the company to sync
116116
*
117117
* @return bool
118118
*/
@@ -128,6 +128,7 @@ public function sync_company( $contact_id, $current_company_id, $company_name ):
128128
if ( $current_company_id !== '0' ) {
129129
if ( ! $this->delete_account_association( $contact_id ) ) {
130130
$this->log( esc_html__( 'There was an error when attempting to delete an association', 'automatewoo' ) );
131+
131132
return false;
132133
}
133134
}
@@ -154,7 +155,7 @@ public function sync_company( $contact_id, $current_company_id, $company_name ):
154155
*
155156
* @see https://developers.activecampaign.com/reference/list-all-accounts
156157
*
157-
* @param string $account_name Name of the account to search for
158+
* @param string $account_name Name of the account to search for
158159
* @param bool $create_missing_account If true then the account will be created if not found
159160
*
160161
* @return bool|array
@@ -227,6 +228,7 @@ public function get_lists(): array {
227228

228229
if ( ! isset( $response['lists'] ) ) {
229230
$this->log( __( 'Unexpected response when trying to retrieve all lists', 'automatewoo' ) );
231+
230232
return [];
231233
}
232234

@@ -246,7 +248,7 @@ public function get_lists(): array {
246248
* @see https://developers.activecampaign.com/reference/update-list-status-for-contact
247249
*
248250
* @param string $contact ID of the contact to add to a list
249-
* @param string $list ID of the list to add the contact to
251+
* @param string $list ID of the list to add the contact to
250252
*
251253
* @return bool
252254
*/
@@ -297,6 +299,7 @@ public function is_contact( $email ) {
297299
public function get_contact( $email ) {
298300
if ( ! is_email( $email ) ) {
299301
$this->log( __( 'Invalid email was supplied when checking if contact exists in ActiveCampaign', 'automatewoo' ) );
302+
300303
return false;
301304
}
302305

@@ -334,6 +337,7 @@ public function get_contact_custom_fields(): array {
334337

335338
if ( ! isset( $response['fields'] ) ) {
336339
$this->log( __( 'Unexpected response when trying to retrieve all custom fields', 'automatewoo' ) );
340+
337341
return [];
338342
}
339343

@@ -351,9 +355,9 @@ public function get_contact_custom_fields(): array {
351355
/**
352356
* Get a tag ID by its name
353357
*
354-
* @param string $tag Name of the tag to get the ID for
358+
* @param string $tag Name of the tag to get the ID for
355359
* @param bool $create_missing_tag If true then the tag will be created if not found
356-
* @param bool $retry_on_error Whether to retry if an error occurs when creating a tag. It will clear the cache and try again.
360+
* @param bool $retry_on_error Whether to retry if an error occurs when creating a tag. It will clear the cache and try again.
357361
*
358362
* @return string|bool
359363
*/
@@ -365,7 +369,7 @@ public function get_tag_id( $tag, $create_missing_tag = false, $retry_on_error =
365369
if ( $cache ) {
366370
$this->active_tags = $cache;
367371
} else {
368-
$response = $this->request( 'tags' )->get_body();
372+
$response = $this->paginated_request( 'tags' );
369373
$this->active_tags = $response['tags'];
370374

371375
Cache::set_transient( $transient, $this->active_tags, 0.15 );
@@ -395,10 +399,12 @@ public function get_tag_id( $tag, $create_missing_tag = false, $retry_on_error =
395399
// Somehow the tag was created by another process in the meantime or externally so we clear the cache and try again.
396400
Cache::delete_transient( $transient );
397401
$this->active_tags = [];
402+
398403
return $this->get_tag_id( $tag, $create_missing_tag, false );
399404
}
400405
// phpcs:disable WordPress.PHP.DevelopmentFunctions
401406
$this->log( 'Unexpected response when attempting to create a tag. Response: ' . print_r( $response, true ) . 'Tags: ' . print_r( $this->active_tags, true ) );
407+
402408
// phpcs:enable
403409
return false;
404410
}
@@ -417,7 +423,7 @@ public function get_tag_id( $tag, $create_missing_tag = false, $retry_on_error =
417423
* Add tags to an existing contact
418424
*
419425
* @param string $contact ID of the contact to add tags to
420-
* @param array $tags An array of tags to add
426+
* @param array $tags An array of tags to add
421427
*
422428
* @return bool
423429
*/
@@ -453,8 +459,8 @@ public function add_tags( $contact, $tags ) {
453459
*
454460
* @see https://developers.activecampaign.com/reference/overview
455461
*
456-
* @param string $path Path to the API endpoint
457-
* @param array $data Data to include with the request
462+
* @param string $path Path to the API endpoint
463+
* @param array $data Data to include with the request
458464
* @param string $method The HTTP method for this request
459465
*
460466
* @return \ActiveCampaign|false
@@ -497,11 +503,43 @@ public function request( $path, $data = [], $method = 'GET' ) {
497503
return $response;
498504
}
499505

500-
501506
/**
502-
* @deprecated
507+
* Send a request to the ActiveCampaign API with pagination
503508
*
509+
* @see https://developers.activecampaign.com/reference/pagination
510+
*
511+
* @param string $path Path to the API endpoint
512+
* @param array $data Data to include with the request
513+
* @param string $method The HTTP method for this request
514+
* @param int $page The page to fetch.
515+
* @param array $results Accumulated results for all the pages.
516+
*
517+
* @return array
518+
*/
519+
public function paginated_request( $path, $data = [], $method = 'GET', $page = 0, $results = [] ) {
520+
521+
// Set offset based on the $page and the api_pagination_limit
522+
$data['limit'] = $this->get_api_pagination_limit();
523+
$data['offset'] = $page * $this->get_api_pagination_limit();
524+
525+
// Get elements for the current page and add them to the results.
526+
$request = $this->request( $path, $data, $method )->get_body();
527+
$results = array_merge( $results, $request[ $path ] );
528+
529+
// If there are more elements left. Fetch again with the next page.
530+
if ( $request['meta']['total'] > count( $results ) ) {
531+
return $this->paginated_request( $path, $data, $method, ++$page, $results );
532+
}
533+
534+
return [
535+
$path => $results,
536+
'meta' => [ 'total' => $request['meta']['total'] ],
537+
];
538+
}
539+
540+
/**
504541
* @return void
542+
* @deprecated
505543
*/
506544
protected function get_sdk() {
507545
wc_deprecated_function( __METHOD__, '6.1.0', 'request' );
@@ -518,4 +556,21 @@ public function clear_cache_data() {
518556
Cache::delete_transient( 'ac_tags' );
519557
Cache::delete_transient( 'ac_contact_fields' );
520558
}
559+
560+
561+
/**
562+
* Get the pagination limit.
563+
*
564+
* @return int
565+
*/
566+
public function get_api_pagination_limit() {
567+
568+
/**
569+
* Filter the pagination limit for Active Campaign REST API.
570+
*
571+
* @since 6.0.31
572+
* @filter automatewoo/integrations/active_campaign/pagination
573+
*/
574+
return apply_filters( 'automatewoo/integrations/active_campaign/pagination', 100 );
575+
}
521576
}

languages/automatewoo.pot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This file is distributed under the GPLv3.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: AutomateWoo 6.0.30\n"
5+
"Project-Id-Version: AutomateWoo 6.0.31\n"
66
"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/contact-support/\n"
77
"Last-Translator: \n"
88
"Language-Team: \n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2024-07-24T17:39:46+00:00\n"
12+
"POT-Creation-Date: 2024-08-06T09:37:14+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.7.1\n"
1515
"X-Domain: automatewoo\n"
@@ -3692,15 +3692,15 @@ msgstr ""
36923692
msgid "There was an error when attempting to delete an association"
36933693
msgstr ""
36943694

3695-
#: includes/Integrations/ActiveCampaign.php:229
3695+
#: includes/Integrations/ActiveCampaign.php:230
36963696
msgid "Unexpected response when trying to retrieve all lists"
36973697
msgstr ""
36983698

3699-
#: includes/Integrations/ActiveCampaign.php:299
3699+
#: includes/Integrations/ActiveCampaign.php:301
37003700
msgid "Invalid email was supplied when checking if contact exists in ActiveCampaign"
37013701
msgstr ""
37023702

3703-
#: includes/Integrations/ActiveCampaign.php:336
3703+
#: includes/Integrations/ActiveCampaign.php:339
37043704
msgid "Unexpected response when trying to retrieve all custom fields"
37053705
msgstr ""
37063706

vendor/composer/installed.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'woocommerce/automatewoo',
4-
'pretty_version' => 'dev-release/6.0.30',
5-
'version' => 'dev-release/6.0.30',
6-
'reference' => '53d89547a569c204123bd55e57e66c3bbec509ce',
4+
'pretty_version' => 'dev-release/6.0.31',
5+
'version' => 'dev-release/6.0.31',
6+
'reference' => '3197bfafc261bf7a043c22c8c3028f560abfff12',
77
'type' => 'wordpress-plugin',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
1010
'dev' => false,
1111
),
1212
'versions' => array(
1313
'woocommerce/automatewoo' => array(
14-
'pretty_version' => 'dev-release/6.0.30',
15-
'version' => 'dev-release/6.0.30',
16-
'reference' => '53d89547a569c204123bd55e57e66c3bbec509ce',
14+
'pretty_version' => 'dev-release/6.0.31',
15+
'version' => 'dev-release/6.0.31',
16+
'reference' => '3197bfafc261bf7a043c22c8c3028f560abfff12',
1717
'type' => 'wordpress-plugin',
1818
'install_path' => __DIR__ . '/../../',
1919
'aliases' => array(),

0 commit comments

Comments
 (0)