Call marketing extension recommendations API version 1.3 and support Klaviyo in "Installed extensions" card in Marketing page (#38974)

This commit is contained in:
Gan Eng Chin 2023-07-04 17:27:02 +08:00 committed by GitHub
commit ed5737ba87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 1 deletions

View File

@ -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';

View File

@ -0,0 +1,18 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { WC_ASSET_URL } from '~/utils/admin-settings';
const klaviyo = (
<img
src={ `${ WC_ASSET_URL }images/marketing/klaviyo.png` }
alt={ __( 'Klaviyo', 'woocommerce' ) }
/>
);
export default klaviyo;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -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.

View File

@ -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'] = plugins_url( 'assets/images/marketing/klaviyo.png', WC_PLUGIN_FILE );
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.
*

View File

@ -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' ),
)