Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions

DefaultFreeExtensions::with_core_profiler_fieldspublic staticWC 1.0

Decorate plugin data with core profiler fields.

  • Updated description for the core-profiler.
  • Adds learn_more_link and label.
  • Adds install_priority, which is used to sort the plugins. The value is determined by the plugin size. Lower = smaller.

Method of the class: DefaultFreeExtensions{}

No Hooks.

Returns

Array.

Usage

$result = DefaultFreeExtensions::with_core_profiler_fields( $plugins );
$plugins(array) (required)
Array of plugins.

DefaultFreeExtensions::with_core_profiler_fields() code WC 10.7.0

public static function with_core_profiler_fields( array $plugins ) {
	$_plugins = array(
		'woocommerce-payments'                => array(
			/* translators: %s: Payment provider name. */
			'label'            => sprintf( __( 'Get paid with %s', 'woocommerce' ), 'WooPayments' ),
			'image_url'        => self::get_woo_logo(),
			'description'      => __( "Securely accept payments and manage payment activity straight from your store's dashboard", 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/woocommerce-payments?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 5,
			'requires_jpc'     => true,
		),
		'woocommerce-shipping'                => array(
			'label'            => __( 'Save on shipping with WooCommerce Shipping', 'woocommerce' ),
			'image_url'        => self::get_woo_logo(),
			'description'      => __( 'Print discounted USPS, UPS, and DHL labels', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/woocommerce-shipping?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 3,
		),
		'jetpack'                             => array(
			'label'            => __( 'Protect your store and your shoppers with Jetpack', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-jetpack.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Keep your store online with full security and backups', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/jetpack?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 8,
			'requires_jpc'     => true,
		),
		'pinterest-for-woocommerce'           => array(
			'label'            => __( 'Showcase your products with Pinterest', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-pinterest.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Get your products in front of a highly engaged audience.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/pinterest-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 2,
		),
		'kliken-ads-pixel-for-meta'           => array(
			'label'            => __( 'Grow your business with Facebook and Instagram', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-kliken.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Sync your store catalog, set up pixel tracking, and run targeted ad campaigns.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/meta-ads-and-pixel?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 2,
		),
		'mailpoet'                            => array(
			'label'            => __( 'Reach your customers with MailPoet', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-mailpoet.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Send purchase follow-up emails, newsletters, and promotional campaigns.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/mailpoet?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 7,
		),
		'klaviyo'                             => array(
			'label'            => __( 'Klaviyo', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/onboarding/klaviyo.png', WC_PLUGIN_FILE ),
			'description'      => __( 'Grow and retain customers with email, SMS, automations, and a consolidated view of customer interactions.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/klaviyo-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 7,
		),
		'tiktok-for-business'                 => array(
			'label'            => __( 'Create ad campaigns with TikTok', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-tiktok.png', WC_PLUGIN_FILE ),
			'description'      => __( 'Create advertising campaigns and reach one billion global users.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/tiktok-for-woocommerce?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 1,
		),
		'google-listings-and-ads'             => array(
			'label'            => __( 'Drive sales with Google for WooCommerce', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-google.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Reach millions of active shoppers across Google with free product listings and ads.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/google-listings-and-ads?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 6,
		),
		'snapchat-for-woocommerce'            => array(
			'label'            => __( 'Find New Customers with Snapchat Ads', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-snapchat.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Reach an untapped audience on Snapchat and drive more sales.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/snapchat/?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 1,
		),
		'facebook-for-woocommerce'            => array(
			'label'            => __( 'Grow your business with Facebook and Instagram', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-facebook.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'List products and create ads on Facebook and Instagram.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/facebook/?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 2,
		),
		'reddit-for-woocommerce'              => array(
			'label'            => __( 'Find New Customers with Reddit Ads', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-reddit.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Seamlessly sync your products and start Reddit Ads.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/reddit/?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 1,
		),
		'woocommerce-shipstation-integration' => array(
			'label'            => __( 'Print discounted shipping labels with ShipStation', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-shipstation.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Automate your order fulfillment and save on top carriers', 'woocommerce' ),
			'learn_more_link'  => 'https://wordpress.org/plugins/woocommerce-shipstation-integration/',
			'install_priority' => 3,
		),
		'packlink-pro-shipping'               => array(
			'label'            => __( 'Print discounted shipping labels with Packlink', 'woocommerce' ),
			'image_url'        => plugins_url( '/assets/images/core-profiler/logo-packlink.svg', WC_PLUGIN_FILE ),
			'description'      => __( 'Automate your order fulfillment and save on top carriers', 'woocommerce' ),
			'learn_more_link'  => 'https://wordpress.org/plugins/packlink-pro-shipping/',
			'install_priority' => 3,
		),
		'woocommerce-services:tax'            => array(
			'label'            => __( 'Get automated tax rates with WooCommerce Tax', 'woocommerce' ),
			'image_url'        => self::get_woo_logo(),
			'description'      => __( 'Automatically calculate how much sales tax should be collected – by city, country, or state.', 'woocommerce' ),
			'learn_more_link'  => 'https://woocommerce.com/products/tax?utm_source=storeprofiler&utm_medium=product&utm_campaign=freefeatures',
			'install_priority' => 4,
		),
	);

	$_plugins['woocommerce-shipping']['is_visible'] = array(
		array(
			'type'      => 'base_location_country',
			'value'     => 'US',
			'operation' => '=',
		),
	);

	$_plugins['woocommerce-services:tax']['is_visible'] = array(
		self::get_rules_for_wcservices_tax_countries(),
	);

	// TikTok, Pinterest, and Facebook share a single spot with 1/3 rotation each.
	$_plugins['tiktok-for-business']['is_visible'] = array(
		array(
			'type'        => 'option',
			'option_name' => 'woocommerce_remote_variant_assignment',
			'value'       => array( 1, 40 ),
			'default'     => false,
			'operation'   => 'range',
		),
	);

	$_plugins['pinterest-for-woocommerce']['is_visible'] = array(
		array(
			'type'        => 'option',
			'option_name' => 'woocommerce_remote_variant_assignment',
			'value'       => array( 41, 80 ),
			'default'     => false,
			'operation'   => 'range',
		),
	);

	$_plugins['facebook-for-woocommerce']['is_visible'] = array(
		array(
			'type'        => 'option',
			'option_name' => 'woocommerce_remote_variant_assignment',
			'value'       => array( 81, 120 ),
			'default'     => false,
			'operation'   => 'range',
		),
	);

	$remove_plugins_activated_rule = function ( $is_visible ) {
		$is_visible = array_filter(
			array_map(
				function ( $rule ) {
					if ( is_object( $rule ) || ! isset( $rule['operand'] ) ) {
						return $rule;
					}

					return array_filter(
						$rule['operand'],
						function ( $operand ) {
							return 'plugins_activated' !== $operand['type'];
						}
					);
				},
				$is_visible
			)
		);

		return empty( $is_visible ) ? true : $is_visible;
	};

	foreach ( $plugins as &$plugin ) {
		if ( isset( $_plugins[ $plugin['key'] ] ) ) {
			$plugin = array_merge( $plugin, $_plugins[ $plugin['key'] ] );

			if ( isset( $plugin['is_visible'] ) && is_array( $plugin['is_visible'] ) ) {
				$plugin['is_visible'] = $remove_plugins_activated_rule( $plugin['is_visible'] );
			}
		}
	}

	return $plugins;
}