Register server-side tracking during rest requests (#37796)

* Register server-side tracking during rest requests

* Move loading of tracks related functionality to WC class

* Load tracks functions to allow tests to pass

* Move single init hook for WC Site Tracking to core class
This commit is contained in:
Joshua T Flowers 2023-05-01 09:50:58 -07:00 committed by GitHub
parent d014e80a20
commit d86a3d1dab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Register server-side tracking during rest requests

View File

@ -28,7 +28,6 @@ class WC_Admin {
add_action( 'admin_init', array( $this, 'admin_redirects' ) );
add_action( 'admin_footer', 'wc_print_js', 25 );
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
add_action( 'init', array( 'WC_Site_Tracking', 'init' ) );
// Disable WXR export of schedule action posts.
add_filter( 'action_scheduler_post_type_args', array( $this, 'disable_webhook_post_export' ) );
@ -67,12 +66,6 @@ class WC_Admin {
include_once __DIR__ . '/class-wc-admin-importers.php';
include_once __DIR__ . '/class-wc-admin-exporters.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-event.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-client.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-footer-pixel.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-site-tracking.php';
// Help Tabs.
if ( apply_filters( 'woocommerce_enable_admin_help_tab', true ) ) {
include_once __DIR__ . '/class-wc-admin-help.php';

View File

@ -221,6 +221,7 @@ final class WooCommerce {
add_action( 'init', array( 'WC_Emails', 'init_transactional_emails' ) );
add_action( 'init', array( $this, 'add_image_sizes' ) );
add_action( 'init', array( $this, 'load_rest_api' ) );
add_action( 'init', array( 'WC_Site_Tracking', 'init' ) );
add_action( 'switch_blog', array( $this, 'wpdb_table_fix' ), 0 );
add_action( 'activated_plugin', array( $this, 'activated_plugin' ) );
add_action( 'deactivated_plugin', array( $this, 'deactivated_plugin' ) );
@ -532,6 +533,15 @@ final class WooCommerce {
include_once WC_ABSPATH . 'includes/class-wc-auth.php';
include_once WC_ABSPATH . 'includes/class-wc-register-wp-admin-settings.php';
/**
* Tracks.
*/
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-event.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-client.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-footer-pixel.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-site-tracking.php';
/**
* WCCOM Site.
*/