Skip to content

Commit 88c4f44

Browse files
author
Woo
committed
Updates to 6.0.24
1 parent 39e8ee1 commit 88c4f44

File tree

1,211 files changed

+119083
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,211 files changed

+119083
-0
lines changed

admin/Analytics.php

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
namespace AutomateWoo\Admin;
4+
5+
use Automattic\WooCommerce\Admin\PageController;
6+
7+
/**
8+
* AutomateWoo Analytics.
9+
* Formerly AutomateWoo > Reports.
10+
*
11+
* @since 5.6.1
12+
*/
13+
class Analytics {
14+
15+
/**
16+
* Init.
17+
*/
18+
public static function init() {
19+
add_action( 'init', array( __CLASS__, 'setup' ) );
20+
}
21+
22+
/**
23+
* Setup Analytics.
24+
* Add report items and register scripts.
25+
*/
26+
public static function setup() {
27+
if ( self::is_enabled() ) {
28+
// Analytics init.
29+
add_filter( 'woocommerce_analytics_report_menu_items', array( __CLASS__, 'add_report_menu_item' ) );
30+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'register_script' ) );
31+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'register_style' ) );
32+
}
33+
}
34+
35+
/**
36+
* Add "Bundles" as a Analytics submenu item.
37+
*
38+
* @param array $report_pages Report page menu items.
39+
* @return array
40+
*/
41+
public static function add_report_menu_item( $report_pages ) {
42+
43+
$report_pages[] = array(
44+
'id' => 'automatewoo-analytics-runs-by-date',
45+
'title' => '<automatewoo-icon aria-label="AutomateWoo"></automatewoo-icon>' . __( 'Workflows', 'automatewoo' ),
46+
'parent' => 'woocommerce-analytics',
47+
'path' => '/analytics/automatewoo-runs-by-date',
48+
);
49+
$report_pages[] = array(
50+
'id' => 'automatewoo-analytics-email-tracking',
51+
'title' => '<automatewoo-icon aria-label="AutomateWoo"></automatewoo-icon>' . __( 'Email & SMS Tracking', 'automatewoo' ),
52+
'parent' => 'woocommerce-analytics',
53+
'path' => '/analytics/automatewoo-email-tracking',
54+
);
55+
$report_pages[] = array(
56+
'id' => 'automatewoo-analytics-conversions',
57+
'title' => '<automatewoo-icon aria-label="AutomateWoo"></automatewoo-icon>' . __( 'Conversions', 'automatewoo' ),
58+
'parent' => 'woocommerce-analytics',
59+
'path' => '/analytics/automatewoo-conversions',
60+
);
61+
return $report_pages;
62+
}
63+
64+
/**
65+
* Register analytics JS.
66+
*/
67+
public static function register_script() {
68+
if ( ! PageController::is_admin_page() ) {
69+
return;
70+
}
71+
72+
$script_asset = require AW()->admin_path( '/assets/build/analytics.asset.php' );
73+
74+
wp_register_script(
75+
'automatewoo-analytics',
76+
AW()->admin_assets_url( '/build/analytics.js' ),
77+
$script_asset['dependencies'],
78+
$script_asset['version'],
79+
true
80+
);
81+
82+
// Load JS translations.
83+
wp_set_script_translations( 'automatewoo-analytics', 'automatewoo', AW()->path( '/languages' ) );
84+
85+
// Enqueue script.
86+
wp_enqueue_script( 'automatewoo-analytics' );
87+
}
88+
89+
/**
90+
* Register analytics CSS.
91+
*/
92+
public static function register_style() {
93+
if ( PageController::is_admin_page() ) {
94+
wp_enqueue_style(
95+
'automatewoo-analytics',
96+
AW()->admin_assets_url( '/build/analytics.css' ),
97+
[ 'wc-admin-app' ],
98+
AW()->version
99+
);
100+
}
101+
}
102+
103+
/**
104+
* Whether or not the new Analytics reports are enabled.
105+
*
106+
* @return bool
107+
*/
108+
public static function is_enabled() {
109+
$is_enabled = WC()->is_wc_admin_active();
110+
111+
/**
112+
* Whether AutomateWoo's analytics reports should be added to the WooCommerce Analytics menu.
113+
*
114+
* @filter automatewoo/admin/analytics_enabled
115+
*/
116+
return (bool) apply_filters( 'automatewoo/admin/analytics_enabled', $is_enabled );
117+
}
118+
}

admin/Analytics/Rest_API.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace AutomateWoo\Admin\Analytics;
4+
5+
use AutomateWoo\Admin\Analytics;
6+
7+
/**
8+
* AutomateWoo Analytics.
9+
* Formerly AutomateWoo > Reports.
10+
*
11+
* @since 5.6.3
12+
*/
13+
class Rest_API {
14+
15+
/**
16+
* Init.
17+
*/
18+
public static function init() {
19+
add_action( 'init', array( __CLASS__, 'setup' ) );
20+
}
21+
22+
/**
23+
* Setup Analytics.
24+
* Register controllers and data stores.
25+
*/
26+
public static function setup() {
27+
if ( self::is_enabled() ) {
28+
29+
// REST API Controllers.
30+
add_filter( 'woocommerce_admin_rest_controllers', array( __CLASS__, 'add_rest_api_controllers' ) );
31+
32+
// Register data stores.
33+
add_filter( 'woocommerce_data_stores', array( __CLASS__, 'register_data_stores' ) );
34+
35+
}
36+
}
37+
38+
/**
39+
* Whether or not the Rest APIs for Analytic reports are enabled.
40+
*
41+
* @return bool
42+
*/
43+
public static function is_enabled() {
44+
return Analytics::is_enabled();
45+
}
46+
47+
/**
48+
* Adds Analytics REST contollers.
49+
* To be used with `woocommerce_admin_rest_controllers` filter.
50+
*
51+
* @param array $controllers
52+
* @return array Extended with AW Analytics controllers.
53+
*/
54+
public static function add_rest_api_controllers( $controllers ) {
55+
$controllers[] = 'AutomateWoo\Admin\Analytics\Rest_API\Conversions\Controller';
56+
$controllers[] = 'AutomateWoo\Admin\Analytics\Rest_API\Conversions\Stats\Controller';
57+
$controllers[] = 'AutomateWoo\Admin\Analytics\Rest_API\Email_Tracking\Stats_Controller';
58+
$controllers[] = 'AutomateWoo\Admin\Analytics\Rest_API\Unsubscribers\Stats_Controller';
59+
$controllers[] = 'AutomateWoo\Admin\Analytics\Rest_API\Workflow_Runs\Stats_Controller';
60+
61+
return $controllers;
62+
}
63+
64+
/**
65+
* Register Analytics data stores.
66+
* To be used with `woocommerce_data_stores` filter.
67+
*
68+
* @param array $stores
69+
* @return array Extended with AW Analytics stores.
70+
*/
71+
public static function register_data_stores( $stores ) {
72+
$stores['report-conversions-list'] = 'AutomateWoo\Admin\Analytics\Rest_API\Conversions\Store';
73+
$stores['report-conversions-stats'] = 'AutomateWoo\Admin\Analytics\Rest_API\Conversions\Stats\Store';
74+
$stores['report-email-tracking-stats'] = 'AutomateWoo\Admin\Analytics\Rest_API\Email_Tracking\Data_Store';
75+
$stores['report-unsubscribers-stats'] = 'AutomateWoo\Admin\Analytics\Rest_API\Unsubscribers\Data_Store';
76+
$stores['report-workflow-runs-stats'] = 'AutomateWoo\Admin\Analytics\Rest_API\Workflow_Runs\Data_Store';
77+
78+
return $stores;
79+
}
80+
}

0 commit comments

Comments
 (0)