diff --git a/plugins/woocommerce/changelog/fix-37659 b/plugins/woocommerce/changelog/fix-37659 new file mode 100644 index 00000000000..1dc9596de13 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-37659 @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Register server-side tracking during rest requests diff --git a/plugins/woocommerce/includes/admin/class-wc-admin.php b/plugins/woocommerce/includes/admin/class-wc-admin.php index a8e38be1671..cec22effdef 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin.php @@ -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'; diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php index 5ff64ad3b17..5b83720053b 100644 --- a/plugins/woocommerce/includes/class-woocommerce.php +++ b/plugins/woocommerce/includes/class-woocommerce.php @@ -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. */