説明なし

class-wc-status-tracking.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * WooCommerce Status Tracking
  4. *
  5. * @package WooCommerce\Tracks
  6. */
  7. defined( 'ABSPATH' ) || exit;
  8. /**
  9. * This class adds actions to track usage of WooCommerce Orders.
  10. */
  11. class WC_Status_Tracking {
  12. /**
  13. * Init tracking.
  14. */
  15. public function init() {
  16. add_action( 'admin_init', array( $this, 'track_status_view' ), 10 );
  17. }
  18. /**
  19. * Add Tracks events to the status page.
  20. */
  21. public function track_status_view() {
  22. if ( isset( $_GET['page'] ) && 'wc-status' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
  23. $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'status';
  24. WC_Tracks::record_event(
  25. 'status_view',
  26. array(
  27. 'tab' => $tab,
  28. 'tool_used' => isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null,
  29. )
  30. );
  31. if ( 'status' === $tab ) {
  32. wc_enqueue_js(
  33. "
  34. $( 'a.debug-report' ).on( 'click', function() {
  35. window.wcTracks.recordEvent( 'status_view_reports' );
  36. } );
  37. "
  38. );
  39. }
  40. }
  41. }
  42. }