Skip to content

Commit

Permalink
Register server-side tracking during rest requests (woocommerce#37796)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
joshuatf authored May 1, 2023
1 parent d014e80 commit d86a3d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/fix-37659
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Register server-side tracking during rest requests
7 changes: 0 additions & 7 deletions plugins/woocommerce/includes/admin/class-wc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct() {
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' ) );
Expand Down Expand Up @@ -67,12 +66,6 @@ public function includes() {
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';
Expand Down
10 changes: 10 additions & 0 deletions plugins/woocommerce/includes/class-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private function init_hooks() {
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' ) );
Expand Down Expand Up @@ -532,6 +533,15 @@ public function includes() {
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.
*/
Expand Down

0 comments on commit d86a3d1

Please sign in to comment.