Skip to content

Commit

Permalink
WooCommerce Analytics: make it available as module (#15187)
Browse files Browse the repository at this point in the history
* WooCommerce Analytics: add as module

* Stop loading Woo Analytics all the time

* Update module headings to include new module info

Also update the module's support doc link

* Do not show the module as available unless running Woo 3+

* Add new file to whitelist

* Update introduced version to 8.4 release to trigger autoactivation
  • Loading branch information
jeherve authored Mar 31, 2020
1 parent 5d71829 commit df5a13f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/phpcs-whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = [
'modules/verification-tools.php',
'modules/widgets/contact-info.php',
'modules/widgets/social-icons.php',
'modules/woocommerce-analytics.php',
'modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php',
'modules/wpcom-tos/wpcom-tos.php',
'packages',
Expand Down
14 changes: 14 additions & 0 deletions class.jetpack-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ static function is_module_available( $module ) {
return false;
}

/*
* WooCommerce Analytics should only be available
* when running WooCommerce 3+
*/
if (
'woocommerce-analytics' === $module['module']
&& (
! class_exists( 'WooCommerce' )
|| version_compare( WC_VERSION, '3.0', '<' )
)
) {
return false;
}

if ( ( new Status() )->is_development_mode() ) {
return ! ( $module['requires_connection'] );
} else {
Expand Down
1 change: 0 additions & 1 deletion modules/module-extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
'calypsoify/class.jetpack-calypsoify.php',
'plugin-search.php',
'simple-payments/simple-payments.php',
'woocommerce-analytics/wp-woocommerce-analytics.php',
'wpcom-block-editor/class-jetpack-wpcom-block-editor.php',
'wpcom-tos/wpcom-tos.php',
);
Expand Down
7 changes: 7 additions & 0 deletions modules/module-headings.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ function jetpack_get_module_i18n( $key ) {
'description' => _x( 'Provides additional widgets for use on your site.', 'Module Description', 'jetpack' ),
),

'woocommerce-analytics' => array(
'name' => _x( 'WooCommerce Analytics', 'Module Name', 'jetpack' ),
'description' => _x( 'Enhanced analytics for WooCommerce and Jetpack users.', 'Module Description', 'jetpack' ),
),

'wordads' => array(
'name' => _x( 'Ads', 'Module Name', 'jetpack' ),
'description' => _x( 'Earn income by allowing Jetpack to display high quality ads.', 'Module Description', 'jetpack' ),
Expand All @@ -234,6 +239,7 @@ function jetpack_get_module_i18n_tag( $key ) {
// Modules with `Other` tag:
// - modules/contact-form.php
// - modules/notes.php
// - modules/woocommerce-analytics.php
'Other' =>_x( 'Other', 'Module Tag', 'jetpack' ),

// Modules with `Photos and Videos` tag:
Expand Down Expand Up @@ -300,6 +306,7 @@ function jetpack_get_module_i18n_tag( $key ) {
// - modules/sharedaddy.php
// - modules/sitemaps.php
// - modules/stats.php
// - modules/woocommerce-analytics.php
'Recommended' =>_x( 'Recommended', 'Module Tag', 'jetpack' ),

// Modules with `General` tag:
Expand Down
2 changes: 1 addition & 1 deletion modules/module-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ function jetpack_google_analytics_more_info() {
* WooCommerce Analytics support link.
*/
function jetpack_woocommerce_analytics_more_link() {
echo 'https://jetpack.com/support/';
echo 'https://jetpack.com/support/woocommerce-analytics/';
}
add_action( 'jetpack_learn_more_button_woocommerce-analytics', 'jetpack_woocommerce_analytics_more_link' );

Expand Down
22 changes: 22 additions & 0 deletions modules/woocommerce-analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Module Name: WooCommerce Analytics
* Module Description: Enhanced analytics for WooCommerce and Jetpack users.
* Sort Order: 13
* First Introduced: 8.4
* Requires Connection: Yes
* Auto Activate: Yes
* Module Tags: Other, Recommended
* Feature: Engagement
* Additional Search Queries: woocommerce, analytics, stats, statistics, tracking, analytics, views
*
* @package Jetpack
*/

/**
* Load module functionality.
*/
function jetpack_load_woocommerce_analytics() {
require_once dirname( __FILE__ ) . '/woocommerce-analytics/wp-woocommerce-analytics.php';
}
jetpack_load_woocommerce_analytics();

0 comments on commit df5a13f

Please sign in to comment.