From c00f56909157d44687665b404ea53923817aa0ab Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Tue, 27 Jun 2023 23:28:32 +0800 Subject: [PATCH 1/7] Add Klaviyo logo icon. --- .../assets/images/marketing/klaviyo.png | Bin 0 -> 3052 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 plugins/woocommerce/assets/images/marketing/klaviyo.png diff --git a/plugins/woocommerce/assets/images/marketing/klaviyo.png b/plugins/woocommerce/assets/images/marketing/klaviyo.png new file mode 100644 index 0000000000000000000000000000000000000000..781a41965411fdcfc8590983f84fff2b141f6ac9 GIT binary patch literal 3052 zcmcImdpK0<8ec{eMv694ZbO%$%oQ=yj7x?P#WY7mnq_7UGG?ZkHDl7n5W6T;yX>DNpfXVghrL}wBWOD$RAd6*(!l8iyG_EL~ z0P;jp5J3?yM$iC2cUOo(ZX5(-qoC+mAp_U{n+k`GoG~`{aCgKo~gvY0`m_B0=L}K7#U|38e z5)%><2nmh^ktCW(rc$Xy5`{>i;1L8~x>g8-3cOG{6Jfw$H5^Px%9X^5;aHIntL6lw zL^7Cx!(p&v)SfUbiH#a(7fK1BMk7SUV+a#7r1ey`xafy%siid=-x=G}*Ch@p5I2IN_Ut8oUfWL1MGJ7-uD2!&{6nGxQ z2W0{n=jOR;u>h3Et`%W@1Yk6lOmS5p>o0N}qoWhQiS&PDCjMr=)f1>WX6o5P3`kmz zV`(80%~J-)h$L>@7zxN1h!P-)l&(hoM~{rXruhF;fsu1LUg7Vyp#a6-903GI(~Pc2 z!WM}HZeE~J4$_G~s{e8;qq{>+Hgd*^<2L~!jNc`Y5V=4k$W8J5{j=KupkwLB^kgdz zyvqH2lKl_kM%B7JN5=%K>%07q_}*KeT%Fovi%LV?+_~_G-P8u1yA9EWAH9aPc7B{c zJ8{p^WD~~i-dy&a8BxP6`m?GJ6|{HMJiq?A_tunXKHc#TQP+WL>FFsEPhMUpY$@(4^f0Ln9HVodA z*`z9a-Y&j6!>Mnxp>3J!cpxz1j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96}?r3R*is6ssh#0jhf3v|` z%(fAbDNRmw{gNf@A0o|ek#`NJXX@>@rNyZF2HV^-y7bO3QVu3rdZmxFP0f0HP~1EF xZ~Pkk_{EW*UvcN*M4y@R=;)%p`J@>ir#%gHuPAmNdaeFH?&rOPd1fIe<=^L$xOD&k literal 0 HcmV?d00001 From 9d473adeb7aabe5f05e10919e93cfd50b2e253a4 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Tue, 27 Jun 2023 23:29:16 +0800 Subject: [PATCH 2/7] Make Klaviyo icon shows up in installed extensions card. --- .../components/product-icon/icons/index.js | 3 +++ .../product-icon/icons/library/klaviyo.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/woocommerce-admin/client/marketing/components/product-icon/icons/library/klaviyo.js diff --git a/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/index.js b/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/index.js index 847759fd058..d2b856797ff 100644 --- a/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/index.js +++ b/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/index.js @@ -31,6 +31,9 @@ export { default as mailchimpForWoocommerce } from './library/mailchimp'; // MailPoet export { default as mailpoet } from './library/mailpoet'; +// Klaviyo +export { default as klaviyo } from './library/klaviyo'; + // Creative Mail by Constant Contact export { default as creativeMailByConstantContact } from './library/creative-mail'; diff --git a/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/library/klaviyo.js b/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/library/klaviyo.js new file mode 100644 index 00000000000..640434fc5f3 --- /dev/null +++ b/plugins/woocommerce-admin/client/marketing/components/product-icon/icons/library/klaviyo.js @@ -0,0 +1,18 @@ +/** + * External dependencies + */ +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import { WC_ASSET_URL } from '~/utils/admin-settings'; + +const klaviyo = ( + { +); + +export default klaviyo; From ac3097227cf160131aa0ee8446571780d4b45ca6 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Tue, 27 Jun 2023 23:33:03 +0800 Subject: [PATCH 3/7] Make Klaviyo show up in installed extensions card. --- .../Admin/Marketing/InstalledExtensions.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php index b1e9ad82b80..d5b47d19927 100644 --- a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php +++ b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php @@ -29,6 +29,7 @@ class InstalledExtensions { $google = self::get_google_extension_data(); $amazon_ebay = self::get_amazon_ebay_extension_data(); $mailpoet = self::get_mailpoet_extension_data(); + $klaviyo = self::get_klaviyo_extension_data(); $creative_mail = self::get_creative_mail_extension_data(); $tiktok = self::get_tiktok_extension_data(); $jetpack_crm = self::get_jetpack_crm_extension_data(); @@ -73,6 +74,10 @@ class InstalledExtensions { $data[] = $mailpoet; } + if ( $klaviyo ) { + $data[] = $klaviyo; + } + if ( $creative_mail ) { $data[] = $creative_mail; } @@ -380,6 +385,33 @@ class InstalledExtensions { return $data; } + /** + * Get Klaviyo extension data. + * + * @return array|bool + */ + protected static function get_klaviyo_extension_data() { + $slug = 'klaviyo'; + + if ( ! PluginsHelper::is_plugin_installed( $slug ) ) { + return false; + } + + $data = self::get_extension_base_data( $slug ); + $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/klaviyo.png'; + + if ( 'activated' === $data['status'] ) { + $klaviyo_options = get_option('klaviyo_settings'); + if (isset($klaviyo_options['klaviyo_public_api_key'])) { + $data['status'] = 'configured'; + } + + $data['settingsUrl'] = admin_url( 'admin.php?page=klaviyo_settings' ); + } + + return $data; + } + /** * Get Creative Mail for WooCommerce extension data. * From d53192f30a6bf7736f17e465d1fc5b0167f53c5b Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Wed, 28 Jun 2023 00:11:37 +0800 Subject: [PATCH 4/7] Call marketing extensions recommendations API version 1.3. Version 1.3 contains new recommendation Klaviyo extension. --- .../woocommerce/src/Internal/Admin/Marketing/MarketingSpecs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Internal/Admin/Marketing/MarketingSpecs.php b/plugins/woocommerce/src/Internal/Admin/Marketing/MarketingSpecs.php index e6ed4e875d9..b80b93a16a4 100644 --- a/plugins/woocommerce/src/Internal/Admin/Marketing/MarketingSpecs.php +++ b/plugins/woocommerce/src/Internal/Admin/Marketing/MarketingSpecs.php @@ -52,7 +52,7 @@ class MarketingSpecs { if ( false === $plugins ) { $request = wp_remote_get( - 'https://woocommerce.com/wp-json/wccom/marketing-tab/1.2/recommendations.json', + 'https://woocommerce.com/wp-json/wccom/marketing-tab/1.3/recommendations.json', array( 'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ), ) From f8b509a710a3fd218b5d15fe90f53f4269185ed9 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Thu, 29 Jun 2023 19:00:02 +0800 Subject: [PATCH 5/7] Add changelog. --- plugins/woocommerce/changelog/add-klaviyo-marketing-extension | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/woocommerce/changelog/add-klaviyo-marketing-extension diff --git a/plugins/woocommerce/changelog/add-klaviyo-marketing-extension b/plugins/woocommerce/changelog/add-klaviyo-marketing-extension new file mode 100644 index 00000000000..dbd67ef5bb7 --- /dev/null +++ b/plugins/woocommerce/changelog/add-klaviyo-marketing-extension @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Update the call to marketing extensions recommendations API from version 1.2 to version 1.3 with new recommendation Klaviyo. From bb8079def84bd204ca6929baf26bc77e313a7428 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Thu, 29 Jun 2023 19:12:48 +0800 Subject: [PATCH 6/7] Fix PHP lint issues. --- .../woocommerce/src/Admin/Marketing/InstalledExtensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php index d5b47d19927..62779c3addd 100644 --- a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php +++ b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php @@ -401,8 +401,8 @@ class InstalledExtensions { $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/klaviyo.png'; if ( 'activated' === $data['status'] ) { - $klaviyo_options = get_option('klaviyo_settings'); - if (isset($klaviyo_options['klaviyo_public_api_key'])) { + $klaviyo_options = get_option( 'klaviyo_settings' ); + if ( isset( $klaviyo_options['klaviyo_public_api_key'] ) ) { $data['status'] = 'configured'; } From f36b00021b71dc95483baf0b1cc4d89641721eb4 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Fri, 30 Jun 2023 00:29:09 +0800 Subject: [PATCH 7/7] Replace deprecated WC_ADMIN_IMAGES_FOLDER_URL with plugins_url function call. Co-authored-by: Jeremy Pry --- plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php index 62779c3addd..9f077130e17 100644 --- a/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php +++ b/plugins/woocommerce/src/Admin/Marketing/InstalledExtensions.php @@ -398,7 +398,7 @@ class InstalledExtensions { } $data = self::get_extension_base_data( $slug ); - $data['icon'] = WC_ADMIN_IMAGES_FOLDER_URL . '/marketing/klaviyo.png'; + $data['icon'] = plugins_url( 'assets/images/marketing/klaviyo.png', WC_PLUGIN_FILE ); if ( 'activated' === $data['status'] ) { $klaviyo_options = get_option( 'klaviyo_settings' );